Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel coverage fails when bazel test successful #1260

Closed
arunkant opened this issue Jun 8, 2023 · 3 comments
Closed

bazel coverage fails when bazel test successful #1260

arunkant opened this issue Jun 8, 2023 · 3 comments
Labels
Can Close? Will close in 30 days if there is no new activity

Comments

@arunkant
Copy link

arunkant commented Jun 8, 2023

🐞 bug report

Affected Rule

The issue is caused by the rule: py_test

Is this a regression?

Don't know

Description

We are trying to run django tests through bazel. bazel test ... command is working fine but bazel coverage ... fails with error

ModuleNotFoundError: No module named 'settings'

🔬 Minimal Reproduction

🔥 Exception or Error


Traceback (most recent call last):
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/qureai/packages/python/image_manager/tests/main.py", line 13, in 
    execute_from_command_line(
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/base.py", line 346, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/base.py", line 320, in create_parser
    self.add_arguments(parser)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/core/management/commands/test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/test/utils.py", line 317, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/execroot/qureai/bazel-out/k8-fastbuild/bin/packages/python/image_manager/image_manager_test.runfiles/python_deps_django/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/tmp/arunkant/bazel/_bazel_arunkant/e454b3605424c5208f266bd2853bae79/external/python3_9_x86_64-unknown-linux-gnu/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1030, in _gcd_import
  File "", line 1007, in _find_and_load
  File "", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'settings'


🌍 Your Environment

Operating System:

  
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
  

Output of bazel version:

  
6.2.0
  

Rules_python version:

  
0.21.0
  

Anything else relevant?

If bazel test works then I expect bazel coverage to work with it

Copy link

github-actions bot commented Dec 5, 2023

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

@github-actions github-actions bot added the Can Close? Will close in 30 days if there is no new activity label Dec 5, 2023
Copy link

github-actions bot commented Jan 4, 2024

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

@linzhp
Copy link
Contributor

linzhp commented Jul 2, 2024

Fixed by --@rules_python//python/config_settings:bootstrap_impl=script from #1929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days if there is no new activity
Projects
None yet
Development

No branches or pull requests

2 participants