Skip to content

Commit

Permalink
labm8/py/test: Move global conftest into //labm8/py/internal.
Browse files Browse the repository at this point in the history
This moves the conftest.py file at the root of the WORKSPACE into a
module in //labm8/py/internal that is explicitly loaded as a plugin by
//labm8/py:test.

This is part of the ongoing process to eliminate conftest.py files
from the repo and to enable --noconftest arg in pytest.

github.com//issues/70

Signed-off-by: format 2020.01.16 <github.com/ChrisCummins/format>
  • Loading branch information
ChrisCummins committed Jan 25, 2020
1 parent 3c7adf8 commit 72d781f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
12 changes: 0 additions & 12 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ python_grpc_library(
deps = ["//:config_pb"],
)

py_library(
name = "conftest",
testonly = 1,
srcs = ["conftest.py"],
visibility = ["//visibility:public"],
deps = [
"//:build_info",
"//labm8/py:app",
"//third_party/py/pytest",
],
)

# Golang.
# Gazelle directive:
# gazelle:prefix github.com/ChrisCummins/phd
Expand Down
2 changes: 1 addition & 1 deletion labm8/py/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ py_library(
visibility = ["//visibility:public"],
deps = [
":app",
"//:conftest",
"//labm8/py/internal:pytest_plugin",
"//third_party/py/pytest",
],
)
Expand Down
12 changes: 12 additions & 0 deletions labm8/py/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ python_proto_library(
visibility = ["//labm8/py:__subpackages__"],
deps = [":logging_pb"],
)

py_library(
name = "pytest_plugin",
testonly = 1,
srcs = ["pytest_plugin.py"],
visibility = ["//labm8/py:__subpackages__"],
deps = [
"//:build_info",
"//labm8/py:app",
"//third_party/py/pytest",
],
)
2 changes: 1 addition & 1 deletion conftest.py → labm8/py/internal/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Repo-wide pytest configuration and test fixtures."""
"""This module defines a pytest plugin for labm8."""
import pathlib
import socket
import sys
Expand Down
4 changes: 4 additions & 0 deletions labm8/py/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def RunPytestOnFileOrDie(file_path: str, capture_output: bool = None):
file_path,
# Run pytest verbosely.
"-v",
# Enable the labm8 test plugin.
"-p",
"labm8.py.internal.pytest_plugin",
# Let bazel handle caching.
"-p",
"no:cacheprovider",
]
Expand Down

0 comments on commit 72d781f

Please sign in to comment.