Skip to content

Commit

Permalink
labm8/py/test: Remove PYTEST_ARGS module variable.
Browse files Browse the repository at this point in the history
Instead of reading a PYTEST_ARGS attribute on test modules, use bazel
to pass a --pytest_args argument, e.g.

    py_test(
        name = "foo_test",
	srcs = ["foo_test.py"],
	args = ["--pytest_args=--my_arg"],
	deps = [
	     "//labm8/py:test",
	],
    )

Signed-off-by: format 2020.01.16 <github.com/ChrisCummins/format>
  • Loading branch information
ChrisCummins committed Jan 25, 2020
1 parent a8782da commit 279e9e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 1 addition & 0 deletions deeplearning/ml4pl/graphs/labelled/dataflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ py_test(
size = "enormous",
timeout = "eternal",
srcs = ["annotators_benchmark_test.py"],
args = ["--pytest_args=--benchmark-warmup-iterations=2"],
deps = [
":annotate",
":data_flow_graphs",
Expand Down
5 changes: 0 additions & 5 deletions labm8/py/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,6 @@ def RunPytestOnFileOrDie(file_path: str, capture_output: bool = None):
# Add the --pytest_args requested by the user.
pytest_args += FLAGS.pytest_args

# Allow the user to add a PYTEST_ARGS = ['--foo'] list of additional
# arguments.
if hasattr(test_module, "PYTEST_ARGS"):
pytest_args += test_module.PYTEST_ARGS

with CoverageContext(test_module, file_path, pytest_args) as pytest_args:
app.Log(1, "Running pytest with arguments: %s", pytest_args)
ret = pytest.main(pytest_args)
Expand Down

0 comments on commit 279e9e4

Please sign in to comment.