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

Pytest failures due to duplicated test file names #263

Closed
busunkim96 opened this issue Jan 8, 2020 · 3 comments
Closed

Pytest failures due to duplicated test file names #263

busunkim96 opened this issue Jan 8, 2020 · 3 comments
Assignees
Labels
generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@busunkim96
Copy link
Contributor

I generated text-to-speech, which has two versions (v1 and v1beta1). The tests directory looks like this:

tests
└── unit
    ├── texttospeech_v1
    │   └── test_text_to_speech.py
    └── texttospeech_v1beta1
        └── test_text_to_speech.py

The tests run fine with the noxfile provided by the generator --cov={{ api.naming.module_namespace|join("/") }}/{{ api.naming.versioned_module_name }}/, but fail with a less specific invocation like --cov=tests.unit.

___________ ERROR collecting tests/unit/texttospeech_v1beta1/test_text_to_speech.py ____________
import file mismatch:
imported module 'test_text_to_speech' has this __file__ attribute:
  /usr/local/google/home/busunkim/github/google-cloud-python/texttospeech/tests/unit/texttospeech_v1/test_text_to_speech.py
which is not the same as the test file we want to collect:
  /usr/local/google/home/busunkim/github/google-cloud-python/texttospeech/tests/unit/texttospeech_v1beta1/test_text_to_speech.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules

According to pytest-dev/pytest#3151, every test file name should be distinct name or there should be __init__.py files. The monolith seems to go the route of having distinct names for every file.

tests
├── system
│   └── gapic
│       ├── v1
│       │   └── test_system_speech_v1.py
│       └── v1p1beta1
│           └── test_system_speech_v1p1beta1.py
└── unit
    ├── gapic
    │   ├── v1
    │   │   └── test_speech_client_v1.py
    │   └── v1p1beta1
    │       └── test_speech_client_v1p1beta1.py
    └── test_helpers.py
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jan 9, 2020
@software-dov software-dov added generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. labels Jan 9, 2020
@software-dov
Copy link
Contributor

Leaning towards having an __init__.py file unless you feel strongly otherwise.
Mild soapbox: names should be short and pithy, paths should be detailed and descriptive.

@busunkim96
Copy link
Contributor Author

@software-dov That sounds good to me.

@busunkim96
Copy link
Contributor Author

Closed by #270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants