Skip to content

Commit c45b4f7

Browse files
committed
[test_OMCPath] update test
1 parent 9416597 commit c45b4f7

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

tests/test_OMCPath.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ def test_OMCPath_docker():
2020
om = OMPython.OMCSessionZMQ(omc_process=omcp)
2121
assert om.sendExpression("getVersion()") == "OpenModelica 1.25.0"
2222

23-
p1 = om.omcpath('/tmp')
24-
assert str(p1) == "/tmp"
25-
p2 = p1 / 'test.txt'
26-
assert str(p2) == "/tmp/test.txt"
23+
tempdir = '/tmp'
24+
25+
p1 = om.omcpath(tempdir).resolve().absolute()
26+
assert str(p1) == tempdir
27+
p2 = p1 / '..' / p1.name / 'test.txt'
28+
assert p2.is_file() is False
2729
assert p2.write_text('test')
30+
assert p2.is_file()
31+
p2 = p2.resolve().absolute()
32+
assert str(p2) == f"{tempdir}/test.txt"
2833
assert p2.read_text() == "test"
2934
assert p2.is_file()
3035
assert p2.parent.is_dir()
@@ -39,11 +44,20 @@ def test_OMCPath_docker():
3944
def test_OMCPath_local():
4045
om = OMPython.OMCSessionZMQ()
4146

42-
p1 = om.omcpath('/tmp')
43-
assert str(p1) == "/tmp"
44-
p2 = p1 / 'test.txt'
45-
assert str(p2) == "/tmp/test.txt"
47+
# use different tempdir for Windows and Linux
48+
if sys.platform.startswith("win"):
49+
tempdir = 'C:/temp'
50+
else:
51+
tempdir = '/tmp'
52+
53+
p1 = om.omcpath(tempdir).resolve().absolute()
54+
assert str(p1) == tempdir
55+
p2 = p1 / '..' / p1.name / 'test.txt'
56+
assert p2.is_file() is False
4657
assert p2.write_text('test')
58+
assert p2.is_file()
59+
p2 = p2.resolve().absolute()
60+
assert str(p2) == f"{tempdir}/test.txt"
4761
assert p2.read_text() == "test"
4862
assert p2.is_file()
4963
assert p2.parent.is_dir()

0 commit comments

Comments
 (0)