-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconftest.py
101 lines (89 loc) · 2.63 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import pytest
import csv
import json
import yaml
@pytest.fixture
def artists_csv_str():
data = """
name,age,genre,albums_sold,hometown,active,label
John,34,Rock,10000,New York,True,Sony
Paul,36,Pop,,Liverpool,True,EMI
George,35,Rock,8000,Liverpool,False,EMI
Ringo,33,Pop,7000,Liverpool,True,EMI
Mick,37,Rock,12000,London,True,Decca
Keith,35,Rock,11000,London,True,Decca
Charlie,33,Jazz,6000,London,True,Decca
Ronnie,32,Blues,5000,London,True,Decca
Roger,34,Rock,9000,London,True,Track
Pete,35,Rock,8500,London,True,Track
John,33,Pop,7500,London,True,Track
Keith,32,Rock,6500,London,True,Track
Robert,34,Rock,9500,London,True,Atlantic
Jimmy,35,Blues,8000,London,True,Atlantic
John Paul,33,Rock,7000,London,True,Atlantic
"""
return data.strip()
@pytest.fixture
def artists_csv():
return csv.reader(artists_csv_str().splitlines())
@pytest.fixture
def cars_json_str():
data = """
[
{"make": "Toyota", "model": "Corolla", "year": 2005, "color": "Blue", "price": 5000},
{"make": "Honda", "model": "Civic", "year": 2006, "color": "Red", "price": 6000},
{"make": "Ford", "model": "Focus", "year": 2007, "color": "White", "price": 7000},
{"make": "Chevrolet", "model": "Cruze", "year": 2008, "color": "Black", "price": 8000},
{"make": "Hyundai", "model": "Elantra", "year": 2009, "color": "Silver", "price": 9000},
{"make": "Nissan", "model": "Sentra", "year": 2010, "color": "Blue", "price": 10000},
{"make": "Volkswagen", "model": "Jetta", "year": 2011, "color": "Red", "price": 11000},
{"make": "Subaru", "model": "Impreza", "year": 2012, "color": "White", "price": 12000},
{"make": "Mazda", "model": "3", "year": 2013, "color": "Black", "price": 13000},
{"make": "Kia", "model": "Forte", "year": 2014, "color": "Silver", "price": 14000}
]
"""
return data
@pytest.fixture
def cars_json():
return json.loads(cars_json_str())
@pytest.fixture
def toys_yaml_str():
data = """
- name: Teddy Bear 🧸
type: Stuffed Animal
color: Brown
age_range: 1-3
price: 20
manufacturer: Hasbro
in_stock: true
weight: 0.5
dimensions: "12 x 8 x 5"
safety_certified: true
country_of_origin: China
- name: Race Car 🏎️
type: Toy Car
color: Red
age_range: 3-5
price: 25
manufacturer: Mattel
in_stock: true
weight: 0.75
dimensions: "8 x 4 x 3"
safety_certified: true
country_of_origin: USA
- name: Doll 🎎
type: Doll
color: null
age_range: 3-5
price: 30
manufacturer: Mattel
in_stock: false
weight: 0.5
dimensions: "12 x 4 x 2"
safety_certified: true
country_of_origin: China
"""
return data
@pytest.fixture
def toys_yaml():
return yaml.safe_load(toys_yaml_str())