Skip to content

Commit

Permalink
fix the imports on the filter directory test (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiuto authored Nov 13, 2023
1 parent e97d155 commit b5d3071
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
7 changes: 7 additions & 0 deletions pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,11 @@ py_binary(
visibility = ["//visibility:public"],
)

py_library(
name = "filter_directory_lib",
srcs = ["filter_directory.py"],
srcs_version = "PY3",
visibility = ["//visibility:public"],
)

exports_files(["verify_archive_test_main.py.tpl"])
6 changes: 4 additions & 2 deletions tests/mappings/filter_directory/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ directory(
py_test(
name = "negative_tests",
srcs = ["test_filter_directory.py"],
data = ["//pkg:filter_directory"],
main = "test_filter_directory.py",
deps = ["@rules_python//python/runfiles"],
deps = [
"//pkg:filter_directory_lib",
"@rules_python//python/runfiles",
],
)
14 changes: 1 addition & 13 deletions tests/mappings/filter_directory/test_filter_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,9 @@
import tempfile
import unittest

from pkg import filter_directory
from python.runfiles import runfiles

# Get the filter_directory script into the import path. There might be a
# better way to do this, but it works.

rf = runfiles.Create()
filter_directory_script = rf.Rlocation('/'.join([
os.environ["TEST_WORKSPACE"],
"pkg",
"filter_directory"
]))

sys.path.append(os.path.dirname(filter_directory_script))
import filter_directory # noqa: E402


# TODO: These tests are largely to ensure that filter_directory fails, but it
# does not check _why_ they fail.
Expand Down

0 comments on commit b5d3071

Please sign in to comment.