Skip to content

Commit e8807b8

Browse files
authored
Fix pytest on windows (#364) (#365)
* Fix pytest on windows (#364) * Slack test even more for WIndows
1 parent 9e303f2 commit e8807b8

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ python_requires = >=3.6
2121
install_requires =
2222
python-can >= 3.0.0
2323
include_package_data = True
24+
25+
[tool:pytest]
26+
testpaths =
27+
test
28+
filterwarnings =
29+
ignore::DeprecationWarning

test/test_eds.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,15 @@ def test_comments(self):
122122

123123
def test_export_eds(self):
124124
import tempfile
125-
for doctype in {"eds", "dcf"}:
126-
with tempfile.NamedTemporaryFile(suffix="." + doctype, mode="w+") as tempeds:
127-
print("exporting %s to " % doctype + tempeds.name)
128-
canopen.export_od(self.od, tempeds, doc_type=doctype)
129-
tempeds.flush()
130-
exported_od = canopen.import_od(tempeds.name)
125+
from pathlib import Path
126+
with tempfile.TemporaryDirectory() as tempdir:
127+
for doctype in {"eds", "dcf"}:
128+
tempfile = str(Path(tempdir, "test." + doctype))
129+
with open(tempfile, "w+") as tempeds:
130+
print("exporting %s to " % doctype + tempeds.name)
131+
canopen.export_od(self.od, tempeds, doc_type=doctype)
132+
133+
exported_od = canopen.import_od(tempfile)
131134

132135
for index in exported_od:
133136
self.assertIn(exported_od[index].name, self.od)

test/test_network.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def test_send_perodic(self):
5959

6060
task = self.network.send_periodic(0x123, [1, 2, 3], 0.01)
6161
time.sleep(0.1)
62-
self.assertTrue(9 <= bus.queue.qsize() <= 11)
62+
# FIXME: This test is a little fragile, as the number of elements
63+
# depends on the timing of the machine.
64+
print("Queue size: %s" % (bus.queue.qsize(),))
65+
self.assertTrue(9 <= bus.queue.qsize() <= 13)
6366
msg = bus.recv(0)
6467
self.assertIsNotNone(msg)
6568
self.assertSequenceEqual(msg.data, [1, 2, 3])

0 commit comments

Comments
 (0)