Skip to content

Commit

Permalink
Fix pytest on windows (#364) (#365)
Browse files Browse the repository at this point in the history
* Fix pytest on windows (#364)

* Slack test even more for WIndows
  • Loading branch information
sveinse authored Apr 8, 2023
1 parent 9e303f2 commit e8807b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ python_requires = >=3.6
install_requires =
python-can >= 3.0.0
include_package_data = True

[tool:pytest]
testpaths =
test
filterwarnings =
ignore::DeprecationWarning
15 changes: 9 additions & 6 deletions test/test_eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ def test_comments(self):

def test_export_eds(self):
import tempfile
for doctype in {"eds", "dcf"}:
with tempfile.NamedTemporaryFile(suffix="." + doctype, mode="w+") as tempeds:
print("exporting %s to " % doctype + tempeds.name)
canopen.export_od(self.od, tempeds, doc_type=doctype)
tempeds.flush()
exported_od = canopen.import_od(tempeds.name)
from pathlib import Path
with tempfile.TemporaryDirectory() as tempdir:
for doctype in {"eds", "dcf"}:
tempfile = str(Path(tempdir, "test." + doctype))
with open(tempfile, "w+") as tempeds:
print("exporting %s to " % doctype + tempeds.name)
canopen.export_od(self.od, tempeds, doc_type=doctype)

exported_od = canopen.import_od(tempfile)

for index in exported_od:
self.assertIn(exported_od[index].name, self.od)
Expand Down
5 changes: 4 additions & 1 deletion test/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def test_send_perodic(self):

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

0 comments on commit e8807b8

Please sign in to comment.