8000 Fix handling paths like `path/file.py/../file.robot` · pythonthings/robotframework@0e523c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e523c6

Browse files
committed
Fix handling paths like path/file.py/../file.robot
1 parent cbb9144 commit 0e523c6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/robot/running/builder/suitestructure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,25 @@ def _get_extensions(self, extension):
5353
return {ext.lower().lstrip('.') for ext in extension.split(':')}
5454

5555
def build(self, paths):
56-
paths = self._validate_paths(paths)
56+
paths = list(self._normalize_paths(paths))
5757
if len(paths) == 1:
5858
return self._build(paths[0], self.include_suites)
5959
children = [self._build(p, self.include_suites) for p in paths]
6060
return SuiteStructure(children=children)
6161

62-
def _validate_paths(self, paths):
62+
def _normalize_paths(self, paths):
6363
if not paths:
6464
raise DataError('One or more source paths required.')
6565
for path in paths:
66+
path = os.path.normpath(path)
6667
if not os.path.exists(path):
6768
raise DataError("Parsing '%s' failed: File or directory to "
6869
"execute does not exist." % path)
69-
return [abspath(p) for p in paths]
70+
yield abspath(path)
7071

7172
def _build(self, path, include_suites):
72-
if not os.path.exists(path) or os.path.isfile(path):
73+
if os.path.isfile(path):
7374
return SuiteStructure(path)
74-
7575
include_suites = self._get_include_suites(path, include_suites)
7676
init_file, paths = self._get_child_paths(path, include_suites)
7777
children = [self._build(p, include_suites) for p in paths]

utest/api/test_exposed_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def test_result_objects(self):
4343

4444

4545
class TestTestSuiteBuilder(unittest.TestCase):
46-
sources = [join(abspath(__file__), '..', '..', '..', 'atest', 'testdata', 'misc', n)
47-
for n in ('pass_and_fail.robot', 'normal.robot')]
46+
# This list has paths like `/path/file.py/../file.robot` on purpose.
47+
# They don't work unless normalized.
48+
sources = [join(__file__, '../../../atest/testdata/misc', name)
49+
for name in ('pass_and_fail.robot', 'normal.robot')]
4850

4951
def test_create_with_datasources_as_list(self):
5052
suite = api.TestSuiteBuilder().build(*self.sources)

0 commit comments

Comments
 (0)
0