I’m using vscode as IDE
I have code a very simple usage of pytest fixture but it doesn’t working when basic example fixture found in the pytest documentation are working well :
JavaScript
x
32
32
1
@pytest.fixture
2
def declare_hexidict():
3
hd = hexidict()
4
rvc = ReferenceValueCluster()
5
rv = ReferenceValue(init=3)
6
hd_var = (hd, rvc, rv)
7
return hd_var
8
9
def setitem_getitem(declare_hexidict):
10
print('start')
11
# hd = hexidict()
12
# rvc = ReferenceValueCluster()
13
# rv = ReferenceValue(init=3)
14
hd, rvc, rv = declare_hexidict
15
print('datastruct defined')
16
hd[rvc("key1").reflink] = rv[0].reflink
17
hd[rvc["key1"]] == rv[0]
18
assert rvc["key1"] in hd.keys(), "key :{} is not int this hexidict".format(
19
rvc("key1")
20
)
21
assert hd[rvc["key1"]] == rv[0], "key :{} return {} instead of {}".format(
22
rvc["key1"], hd[rvc["key1"]], rv[0]
23
)
24
#set non value item (on set une liste)
25
hd[rvc("key2").reflink] = [rv[1].reflink]
26
hd[rvc["key2"]]
27
assert type(hd[rvc["key2"]]) == list
28
29
#on verifie que l'item dans la list est bien celui qui provient de rv
30
assert hd[rvc["key2"]][0] in rv
31
32
I get in the test summary info :
JavaScript
1
3
1
ERROR test/process/hexidict/test_hd_basic_function.py - TypeError: setitem_getitem() missing 1 required positional argument: 'declare_hexidict'
2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3
Advertisement
Answer
pytest does not recognize setitem_getitem like test, so you should rename it to test_setitem_getitem and try it out:
JavaScript
1
2
1
def test_setitem_getitem(declare_hexidict):
2