Skip to content

Commit 2122c6a

Browse files
authored
use path.join for better compatibility with windows (qiskit-community/qiskit-aqua#919)
1 parent 2cfdb8f commit 2122c6a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/optimization/test_quadratic_program.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import unittest
1818
import tempfile
19+
from os import path
1920
from test.optimization.optimization_test_case import QiskitOptimizationTestCase
2021

2122
from docplex.mp.model import Model, DOcplexException
@@ -481,9 +482,11 @@ def test_write_to_lp_file(self):
481482
q_p.quadratic_constraint({'x': 1, 'y': 1}, {('x', 'x'): 1, ('y', 'z'): -1, ('z', 'z'): 2},
482483
'>=', 1, 'quad_geq')
483484

485+
reference_file_name = path.join('test', 'optimization', 'resources',
486+
'test_quadratic_program.lp')
484487
temp_output_file = tempfile.NamedTemporaryFile(mode='w+t', suffix='.lp')
485488
q_p.write_to_lp_file(temp_output_file.name)
486-
with open('test/optimization/resources/test_quadratic_program.lp') as reference:
489+
with open(reference_file_name) as reference:
487490
lines1 = temp_output_file.readlines()
488491
lines2 = reference.readlines()
489492
self.assertListEqual(lines1, lines2)
@@ -492,8 +495,8 @@ def test_write_to_lp_file(self):
492495

493496
with tempfile.TemporaryDirectory() as temp_problem_dir:
494497
q_p.write_to_lp_file(temp_problem_dir)
495-
with open(temp_problem_dir + '/my_problem.lp') as file1, open(
496-
'test/optimization/resources/test_quadratic_program.lp') as file2:
498+
with open(path.join(temp_problem_dir, 'my_problem.lp')) as file1, open(
499+
reference_file_name) as file2:
497500
lines1 = file1.readlines()
498501
lines2 = file2.readlines()
499502
self.assertListEqual(lines1, lines2)

0 commit comments

Comments
 (0)