GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Moving unit tests into dedicated unit_tests/ directory by dhermes · Pull Request #2227 · googleapis/google-cloud-python

Conversation

@dhermes

@dhermes dhermes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

Also moving two _testing.py modules and updating the relevant imports.

As pre-work, removed all unit test imports (i.e. unit tests that imported from another unit test).

See https://gist.github.com/dhermes/a36abffe9d921755d5566c2cb3930be2 for the script I used to generate the 2nd commit. (No code was manually edited, all done by the script.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dhermes dhermes added the testing label Aug 31, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 31, 2016
@dhermes dhermes mentioned this pull request Aug 31, 2016
Running and bundling tests with namespace packages #2225
Closed
@dhermes dhermes assigned tseaver and theacodes Aug 31, 2016
@dhermes

dhermes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor Author

@jonparrott What changes do I need to make to setup.py / MANIFEST.in to make sure Debian package maintainers are happy but also unit_tests/ doesn't end up installed in site-packages?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

@dhermes just add:

graft unit_tests

to MANIFEST.in.

When doing an sdist, setuptools will include that directory in the tar.gz. sdists still use setup.py, so even though the folder is there, it won't be included unless find_packages finds it, which it shouldn't. If it does, use the second argument to ignore it: find_pacakages('.', exclude=('unit_tests')). Note the bdists (including wheels) won't include this folder. This is intentional.

Also, you probably could've kept the situations where tests import other tests by making unit_tests it's own python package (that's just not installed).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor Author

Also, you probably could've kept the situations where tests import other tests by making unit_tests it's own python package (that's just not installed).

That was mostly for good testing hygiene

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

SGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

This LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

I really dislike moving the tests out of line: I believe they should be present in the installed software, on the "fly what you test, test what you fly" principle.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

@tseaver I understand your concern, but it seems that several other major Python packages have tests in a separate directory. We're still providing them in the source distribution.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 31, 2016

Copy link
Copy Markdown
Contributor Author

@tseaver The "responsible" thing to do is to move to the best-in-class and actively maintained test-runner, rather than staying on the dead nose project.

I'm not entirely sure what "fly what you test, test what you fly" has to do with the location of the tests, or sure why it would matter where the tests exist, rather it should matter that they exist.

I don't have any interest in writing a test-runner framework. Provided we're using someone else's, we should do what they support. I can modify my script to go with the second option, which is a dedicated test/ dir (without an __init__.py) in each subpackage.

WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

The "fly what you test" implies shipping the tests with all the distributions, which means not moving them out of the package directory.

I'm -0 about switching to py.test: I can live with that a lot more easily than moving the tests out-of-line.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

@tseaver I can't think of a case where it makes a lot of sense for a binary distribution (wheel) to include tests, especially if we explicitly structure tests to be able to run against the installed library. The clear separation of the tests package from the installed package makes this more obvious - the tester doesn't have to wonder what's being tested.

That is to say, if there is a test at a/test_a.py that tests a.a, it's ambiguous (especially with nose) if the tests are exercising ./a/a.py or {env}/lib/python{x}.{y}/site-packages/a/a.py. By moving the tests to their own package, it's always explicit that the package-under-test is in site-packages.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

Sorry, I'm also confused about how the "Fly as you test, test as you fly" principle applies in this case?
ISTM that means having and adding systems tests as we build which to me would be our CI?

That is to say, if there is a test at a/test_a.py that tests a.a, it's ambiguous (especially with nose) if the tests are exercising ./a/a.py or {env}/lib/python{x}.{y}/site-packages/a/a.py.

In all honesty, I've been burned a couple times by exactly what @jonparrott pointed out there, so I'm game for trying out solutions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

I want users who have installed a wheel to be able to test it without the sdist, e.g.:

  $ /path/to/virtualenv/bin/pip install google-cloud
  $ /path/to/virtualenv/bin/nosetests google.cloud

(or the py.test equvalent). This allows them to verify the installation is correct on their platform. Today, this works (assuming you can navigate borken dependencies yourself):

$ /path/to/virtualenv/bin/pip install googleapis-common-proto==1.2.0 # borken
$ /path/to/virtualenv/bin/pip install nose unittests2 gcloud
$ /path/to/virtualenv/bin/nosetests gcloud
$ /tmp/issue_2227/bin/nosetests gcloud
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SSSSSSSSSS....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 2207 tests in 0.546s

OK (SKIP=10)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

@tseaver basically no other package does this. If that is a strong desire for the user then we should make it easy for them to use the tests in our source tree against an installed version (which is what all the other major packages I linked do), which is what I'm recommending we do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Sep 2, 2016

Copy link
Copy Markdown
Contributor

@jonparrott AYKM? I can point to hundreds which ship the tests inline in the source package.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jgeewax

jgeewax commented Sep 2, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Putting my preferences aside, it looks to me like we have two possible scenarios in the future:

  1. Some standard body says "thou shalt put your tests in site-packages"
  2. Some standard body says "thou shalt not put your tests in site-packages"

If we presume (1) and (2) happens instead, following the standard would mean that we break people who assume they can still type nosetests google.cloud. If we presume (2) and (1) happens instead, we add a feature to meet the standard...

Considering that we both have examples to point to, and a vote today among this group would end up with (2, don't ship tests), and it's the more future-proof option, it seems like we should just not put tests in site-packages and put it down as work to do should a standard be ratified.

Cool?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes added 2 commits September 2, 2016 09:29
@dhermes
Removing unit test imports from other unit tests.
333b6e4
@dhermes
Moving unit tests into dedicated unit_tests/ directory.
6f3ea94
Also moving two _testing.py modules and updating the
relevant imports.
@dhermes
dhermes force-pushed the move-unit-tests branch from a7ff053 to 6f3ea94 Compare September 2, 2016 16:42
@dhermes

dhermes commented Sep 2, 2016

Copy link
Copy Markdown
Contributor Author

@tseaver I'm going with consensus here and merging. We can revisit / we can always put these back. I just don't want to block the other work I'm doing to move to py.test / namespace changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes merged commit 192023d into googleapis:master Sep 2, 2016
@dhermes
dhermes deleted the move-unit-tests branch September 2, 2016 17:43
@tseaver tseaver mentioned this pull request Sep 6, 2016
Add Vision API Face detection. #2224
Merged
@dhermes dhermes mentioned this pull request Sep 19, 2016
Cut 0.19.0 release. #2270
Merged
parthea pushed a commit that referenced this pull request Nov 24, 2025
@release-please
chore(main): release 1.20.0 (#2227)
588b915
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 6, 2026
@chalmerlowe
feat: Adds source_column_match and associated tests (#2227)
08970ad
This commit introduces new configuration options for BigQuery load jobs and external table definitions, aligning with recent updates to the underlying protos.

New options added:

- `source_column_name_match_option`: Controls how source columns are matched to the schema. (Applies to LoadJobConfig, ExternalConfig, LoadJob)

Changes include:
- Added corresponding properties (getters/setters) to `LoadJobConfig`, `LoadJob`, `ExternalConfig`, and `CSVOptions`.
- Updated docstrings and type hints for all new attributes.
- Updated unit tests to cover the new options, ensuring they are correctly handled during object initialization, serialization to API representation, and deserialization from API responses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@tseaver tseaver

@theacodes theacodes

Labels

cla: yes This human has signed the Contributor License Agreement. testing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@dhermes @theacodes @tseaver @daspecster @jgeewax @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.