生成模拟数据的包

pymocko的Python项目详细描述


皮莫科

这是为了生成模拟数据

安装:

python -m pip install pymocko

开发环境:

^{pr2}$

运行测试用例:

cd ..
python run.py

使用的版本

Python 3.7.5

使用

通过模型
print("Mock model")
print(model.mock(schema_json={"id":"num", "name":"word", "qty":"num", "unit_price":"price", "created_at":"date", "updated_at":"date"}, count=5))
print(model.mock(schema_json={"id":"num", "user_name":"word", "name":"word", "dob":"date", "phone_no":"char", "email":"word", "gender":"word", "ip_address":"char"}, count=5))
print(model.mock(schema_json={"id":"num", "name":"word", "qty": { "stocked": "num", "online": "num" }, "price":[ { "unit_price":"price", "effective_date": "date"} ], "created_at":"date", "updated_at":"date"}, count=3))
print(model.mock(schema_json={"id":"num", "name":"word", "tags": ["word"], "reference_names": [ "word" ], "qty": { "stocked": "num", "online": "num" }, "price":[ { "unit_price":"price", "effective_date": "date"} ], "created_at":"date", "updated_at":"date"}, count=3))

随机编号:

from pymocko import num
print(num.mock())
print(num.mock(f=1, t=10))
print(num.mock(f=1, t=1000, neg=True))

随机价格:

from pymocko import price
print(price.mock())
print(price.mock(f=1000, t=10000))
print(price.mock(f=0, t=2500, decimal=0))
print(price.mock(f=0, t=2500, decimal=4))
print(price.mock(f=0, t=2500, neg=True))

随机日期:

from pymocko import date
print(date.mock())
print(date.mock(f=datetime.datetime(2020,6,1)))

随机字符:

from pymocko import char
print(char.mock())
print(char.mock(no_of_char=20,number_inc=True))
print(char.mock(no_of_char=30,number_inc=True,special_inc=True))

随机化单词/句子:

from pymocko import word
print(word.mock()) 
print(word.mock(no_of_word=20))
print(word.mock(no_of_word=10, upper_first=True))
print(word.mock_phone())
print(word.mock_phone(prefix="+84"))
print(word.mock_email())
print(word.mock_email(domain="data.com"))
print(word.mock_gender())

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何向xsi:nil元素添加另一个属性?   Java抽象泛型方法,使用具体类型实现通配符   java使用pcap4j截断pcap文件   当我放置字母a、b和c时,java中的异常预期会下降   java设置活动对话框不可取消   接口类型变量上的Java克隆   使用Java或BouncyCastle对CSR(证书签名请求)进行安全解码/读取   java调用SavingsAccount对象上的函数并打印结果   java如何在Android应用程序上显示地图上的兴趣点(POI)并与之交互?   如果在JavaFX中的ResultSet中未找到任何内容,则显示java警报   java我将springboot和@component与@scheduled一起使用,它每12小时锁定一次   ApachePOI如何使用java删除包含字符串的word表的行   java如果对象(x,y)靠近其他对象(x,y)   从未对JMSException调用java JMS CachingConnectionFactory OneException方法   javascript使用java将HTML页面转换为MS word