def test_find_root(): BAD_PATHS = ( os.path.sep, '.', os.path.sep * 10, '/root/slaves', '/root/slaves/S/frameworks/F/executors//runs/R', 'root/slaves/S/frameworks/F/executors//runs/R', ) GOOD_PATHS = (ExecutorDetector.path(DEFAULT_MATCH), os.path.join(ExecutorDetector.path(DEFAULT_MATCH), 'some', 'other', 'path')) for cwd in BAD_PATHS: assert ExecutorDetector.find_root(cwd) is None for cwd in GOOD_PATHS: assert ExecutorDetector.find_root(cwd) == 'abcd'
def test_find_root(): BAD_PATHS = ( os.path.sep, '.', os.path.sep * 10, '/root/slaves', '/root/slaves/S/frameworks/F/executors//runs/R', 'root/slaves/S/frameworks/F/executors//runs/R', ) GOOD_PATHS = ( ExecutorDetector.path(DEFAULT_MATCH), os.path.join(ExecutorDetector.path(DEFAULT_MATCH), 'some', 'other', 'path') ) for cwd in BAD_PATHS: assert ExecutorDetector.find_root(cwd) is None for cwd in GOOD_PATHS: assert ExecutorDetector.find_root(cwd) == 'abcd'