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

explain more clearly where to put local.py before running tests #12

Open
pdurbin opened this issue Apr 15, 2015 · 7 comments
Open

explain more clearly where to put local.py before running tests #12

pdurbin opened this issue Apr 15, 2015 · 7 comments

Comments

@pdurbin
Copy link
Member

pdurbin commented Apr 15, 2015

To get the tests to run I created ~/.virtualenvs/dataverse-client-python/src/dataverse/dataverse/settings/local.py but I'm not sure if this is right.

murphy:dataverse-client-python pdurbin$ workon dataverse-client-python
(dataverse-client-python)murphy:dataverse-client-python pdurbin$ cd dataverse/test
(dataverse-client-python)murphy:test pdurbin$ python -m unittest test_dataverse
..Connecting to DVN.
E....
======================================================================
ERROR: setUpClass (test_dataverse.TestDatasetOperations)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_dataverse.py", line 98, in setUpClass
    self.dvc = Connection(TEST_HOST, TEST_TOKEN)
  File "/Users/pdurbin/.virtualenvs/dataverse-client-python/src/dataverse/dataverse/connection.py", line 19, in __init__
    self.connect()
  File "/Users/pdurbin/.virtualenvs/dataverse-client-python/src/dataverse/dataverse/connection.py", line 29, in connect
    raise UnauthorizedError('The credentials provided are invalid.')
UnauthorizedError: The credentials provided are invalid.

----------------------------------------------------------------------
Ran 6 tests in 0.138s

FAILED (errors=1)
(dataverse-client-python)murphy:test pdurbin$ vim ~/.virtualenvs/dataverse-client-python/src/dataverse/dataverse/settings/local.py
(dataverse-client-python)murphy:test pdurbin$ cat ~/.virtualenvs/dataverse-client-python/src/dataverse/dataverse/settings/local.py
TEST_HOST = "apitest.dataverse.org"
TEST_TOKEN = "25fe08c4-c7d6-458a-973c-8c461ab4e0ad"
(dataverse-client-python)murphy:test pdurbin$ python -m unittest test_dataverse
..Connecting to DVN.
Getting Dataverse
Removing any existing datasets.
Dataverse emptied.
.....
----------------------------------------------------------------------
Ran 14 tests in 36.141s

OK (skipped=1)
(dataverse-client-python)murphy:test pdurbin$ 
@rliebz
Copy link
Contributor

rliebz commented Apr 15, 2015

To run the tests, you'll want to clone the repo rather than run from the version installed to your virtual env. The readme could specify that.

@pdurbin
Copy link
Member Author

pdurbin commented Apr 15, 2015

Ah, that makes sense. I blew away my virtualenv and made a fresh one. Now I think we should have a requirements.txt file with something like this:

lxml==3.4.3
requests==2.6.0
bleach==1.4.1

After running pip install -r requirements.txt I can run the tests like this:

$ cd dataverse/test
$ vim ../settings/local.py
$ export PYTHONPATH="../.."
$ python -m unittest test_dataverse

Please let me know if this is the wrong approach.

@rliebz
Copy link
Contributor

rliebz commented Apr 16, 2015

That's a fine approach. Because this is intended to be a package, it may be more clear to name the file dev-requirements.txt, since the package requirements are listed in setup.py.

@codersquid
Copy link
Contributor

you could run pip install -e . and not need a requirements.txt file.

@pdurbin
Copy link
Member Author

pdurbin commented Dec 15, 2015

you could run pip install -e . and not need a requirements.txt file.

Well, that seems to install everything under "REQUIRES" at

REQUIRES = [
which is certainly useful ("Successfully installed bleach requests lxml dataverse html5lib six") but I'm also interested in installing everything under "TESTS_REQUIRE" at
TESTS_REQUIRE = [
so I can run the tests. Any ideas?

@codersquid
Copy link
Contributor

@pdurbin In setup.py you could add

setup(
    name='dataverse',
    # ...
    extras_require={
        "testing": TESTS_REQUIRE,
        "somethingsomething": THAT_OTHER_THING,
    }
# and so on

and then pip install -e ".[testing]"

That type of thing drives me crazy because I can never remember the proper syntax and have to look it up every time. ymmv

also, mind you I am typing this by hand and haven't tested it.

@rliebz
Copy link
Contributor

rliebz commented Dec 16, 2015

If you've got the repo cloned locally, the TESTS_REQUIRE packages can be installed (and the test suite run) by running:

$ python setup.py test

I haven't tested this locally, so I'm not sure if setup.py is configured for that to work correctly, but that's generally the idea of the tests_require keyword argument in the setup method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants