Skip to content

Commit 02dd0ff

Browse files
committed
[test_OMCPath] update test
1 parent 4224d94 commit 02dd0ff

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

tests/test_OMCPath.py

Lines changed: 23 additions & 9 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()
@@ -37,13 +42,22 @@ def test_OMCPath_docker():
3742

3843
@skip_python_older_312
3944
def test_OMCPath_local():
40-
om = OMPython.OMCSessionZMQ()
45+
om = OMPython.OMCProcessLocal()
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)