diff --git a/locust/main.py b/locust/main.py index a95374fc99..0069f5f010 100644 --- a/locust/main.py +++ b/locust/main.py @@ -158,6 +158,7 @@ def parse_options(): parser.add_option( '-n', '--num-request', action='store', + type='int', dest='num_requests', default=None, @@ -281,16 +282,18 @@ def find_locustfile(locustfile): return os.path.abspath(expanded) else: # Otherwise, start in cwd and work downwards towards filesystem root - path = '.' - # Stop before falling off root of filesystem (should be platform - # agnostic) - while os.path.split(os.path.abspath(path))[1]: + path = os.path.abspath('.') + while True: for name in names: joined = os.path.join(path, name) if os.path.exists(joined): if name.endswith('.py') or _is_package(joined): return os.path.abspath(joined) - path = os.path.join('..', path) + parent_path = os.path.dirname(path) + if parent_path == path: + # we've reached the root path which has been checked this iteration + break + path = parent_path # Implicit 'return None' if nothing was found