Skip to content

Commit 3c680c1

Browse files
authored
improve path detection (#1021)
* improve path detection * simplify code a bit
1 parent d2945ba commit 3c680c1

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

tests/conftest.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@
3535
logger.setLevel(logging.DEBUG)
3636

3737
file_list = []
38-
directory = None
39-
40-
# finding the root directory of conftest.py and going up to OpenML main directory
41-
# exploiting the fact that conftest.py always resides in the root directory for tests
42-
static_dir = os.path.dirname(os.path.abspath(__file__))
43-
logger.info("static directory: {}".format(static_dir))
44-
while True:
45-
if "openml" in os.listdir(static_dir):
46-
break
47-
static_dir = os.path.join(static_dir, "..")
4838

4939

5040
def worker_id() -> str:
@@ -66,12 +56,11 @@ def read_file_list() -> List[str]:
6656
6757
:return: List[str]
6858
"""
69-
directory = os.path.join(static_dir, "tests/files/")
70-
if worker_id() == "master":
71-
logger.info("Collecting file lists from: {}".format(directory))
72-
files = os.walk(directory)
59+
this_dir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
60+
directory = os.path.join(this_dir, "..")
61+
logger.info("Collecting file lists from: {}".format(directory))
7362
file_list = []
74-
for root, _, filenames in files:
63+
for root, _, filenames in os.walk(directory):
7564
for filename in filenames:
7665
file_list.append(os.path.join(root, filename))
7766
return file_list

0 commit comments

Comments
 (0)