has anyone figured out writing tests and handling ...
# contributing-to-airbyte
c
has anyone figured out writing tests and handling test dependencies in python already in a way that is graceful?
u
I would be interested too!
u
what about handling test deps are you looking for? just importing them for testing only but not package them when shipping the package?
u
i have dependencies that are only releveant to the tests, not the main package.
u
let me try to say that clearer.
u
the tests depend on a library that the main program does not depend on.
u
i want to be able to run
pip install just-my-*******-test-dependencies
u
setup.py looks something like this.
u
Copy code
setup(
    ...
    install_requires=["tap-github==1.9.0", "requests", "base_singer", "airbyte_protocol"],
    tests_require=["base_python_test"],
)
u
but i think tests_require may have been deprecated.
u
going to try to use extras_require
u
u
they also recommend that we move away from
setup.py
to
setup.cfg
u
lol yup.
u
i’m still not entirely sure from a DX point of view how it separates what files are allowed to use test deps versus main deps.
u
maybe you just find out that you screwed up at runtime?
u
does it do any “interesting” separation in the .venv/libs directory?
u
not that i’ve seen so far.
u
but chances are i’m still doing 5 or 6 things wrong.
u
you can use a separate requirements file for dev dependencies
u
that's basically what requirements.txt is already
u
yeah. so i’m doing that.
u
only for testing, because it's doing the editable installs
u
i’m definitely trying to do a weird thing where i want to expose a test module to be run externally.
u
so that’s my bad for not being cookiecutter.
u
I think the module depending on that test module should just link to it using an editable dependency
u
in requirements.txt
u
kk
u
when in the dokcerfile for an integration we run
RUN pip install .
u
that is using the install_reqs or setup right?
u
yeah setup.py
u
i guess that has to be true because we don’t copy of requirements.txt
u
so i think i can do this:
Copy code
extras_require={"standardtest": ["base_python_test", "tap-exchangeratesapi==0.1.1"]},
pip install ".[standardtest]"
u
or something like it
u
but haven’t actually gotten it to work yet
u
I don't know if you can have an editable install within
extras_require
u
i don’t think i’m trying to though.
u
I doubt
base_python_test
is actually installed within the venv you are using
u
Which is probably why it's failing
u
isn’t it the same as
install_requires=["tap-github==1.9.0", "requests", "base_singer", "airbyte_protocol"],
u
base_singer and airbyte_protocol are made available as part of the docker setup
u
they are installed in parent images into the global python scope
u
yeah. i’m doing the same thing with base_python_test
u
does it show up under
pip list
on the image?
u
working on it.
u
also happy to look at the source
u
i’m confused right now, because i was trying to get this out in the virtualenv on my local machine
u
but i think that’s in a dumb state for some reason.
u
i’ll try to build the docker image.
u
if you're trying to get this into your local venv you'll need to install as an editable dependency outside of setup.py
u
kk. dunno what that means tbh. but going to focus on the docker part for now and will try to decipher that later.
u
are you using unittest or pytest?
u
neither
u
no test framework
u
because it’s just passing an interface to the standard tests.
u
ah
u
okay @Jared Rhizor (Airbyte) i think i’ve hit a wall. would you be willing to take a couple minutes to look with me before sync?
u
in a 1:1
u
ah. oaky
u
is there a reason we use _ instead of - here? shouldn’t this refer to the package name? it seems like both resolve, so maybe it doesn’t matter.
Copy code
install_requires=["airbyte_protocol"],
u
package names can't include
-
if i'm not wrong? From PEP:
Copy code
Package and Module Names

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
https://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions
u
Copy code
➜  airbyte git:(master) ✗ pip list
Package            Version    Location
------------------ ---------- ------------------------------
...
importlib-metadata 2.0.0
...
psycopg2-binary    2.8.5
python-dateutil    2.8.1
u
it seems like a lot of them use dashes.
u
ah sorry you are talking about the Pypi package the pep is about the pure python package (that ends up after the
import
directives)
u
oh
u
this is why in requirements.txt you might have
psycopg2-binary
but you actually import
psycopg2_binary
?
u
that confused the hell out of me the first time.