KEMBAR78
Moved package into src folder and added tox for testing by smsearcy · Pull Request #154 · theskumar/python-dotenv · GitHub
Skip to content

Conversation

@smsearcy
Copy link
Contributor

In order to replicate issue #130 for testing purposes I had to run the tests against an installed version of dotenv on Python 2.7. I did this via moving the package into a src directory and use of tox (admittedly because that is the tool I'm familiar with).

I did not change how Travis-CI runs tests but can work on that if there is traction for this change (relatedly, the combined coverage isn't working at the moment either).

Here's some other argument and background for using a src directory:

@coveralls
Copy link

coveralls commented Nov 15, 2018

Coverage Status

Coverage remained the same at 88.502% when pulling 469989b on smsearcy:src-reorg into 569e131 on theskumar:master.

@42B
Copy link

42B commented Nov 15, 2018

Your library does not belong in an ambiguous src or python subdirectory.

?

@jamesmyatt
Copy link

jamesmyatt commented Nov 16, 2018

The links above supersede the advice in the guide. They're worth a read.

@smsearcy
Copy link
Contributor Author

smsearcy commented Nov 20, 2018

The guide is admittedly opinionated advice about how to structure a project and the src directory is definitely debated and there isn't consensus. The first post I linked above links to this long discussion about the recommendation.

Based on my experience it seems that putting a library in a src directory has tangible benefits that outweigh arguments about "ambiguous" directories (such as in this case only being able to replicate a bug when running tests against an installed version of the package). I understand that a PR from an unknown guy on the internet isn't necessarily a basis to change the project but I did the work to confirm my suspicions about #130 and thought it was worth sharing (and could prevent such issues in the future if Travis used tox for testing).

Also, if there is a single sub-directory of src/ GitHub will link directly to it (see attrs for example).

Edit: I just figured out another way to replicate the issue from before, removing tests/__init__.py. The discussion I linked above references the pytest docs which state that if you have a tests/__init__.py then you ought to use a src directory. My main goal was not to re-organize the project but to make sure that the testing is accurate and complete. If @theskumar does not want to re-organize the project (which I would understand) I can modify this PR accordingly.

@theskumar theskumar force-pushed the master branch 2 times, most recently from f628767 to f9863d3 Compare December 16, 2018 13:18
@bbc2
Copy link
Collaborator

bbc2 commented Dec 31, 2018

I like the idea. There might be consequences I'm unable to foresee right now but it sounds worth it. @theskumar What do you think?

It looks like coverage computation is broken. It should probably be fixed by something like the following:

diff --git a/.coveragerc b/.coveragerc
index dedbcd8..9a2049d 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,5 +1,5 @@
 [run]
-source = dotenv/
+source = src

@theskumar
Copy link
Owner

I don't mine changing the directory structure of project. I was really holding on this until the @bbc2's merge request get in, and as expected we have some merge conflicts.

If we can get those resolved, I think we should be good to go. Also, the coverage setup would need to be updated. @smsearcy

@smsearcy
Copy link
Contributor Author

Thank you @theskumar and @bbc2, I will fix the coverage setup and resolve the merge conflicts. I think it would make sense to have Travis run tox now for the test suite, I didn't initially work on that until I knew whether there was interest in the change. What do you think?

@bbc2
Copy link
Collaborator

bbc2 commented Dec 31, 2018

It was a good idea to ask before investing a lot of time in this. If tox is the way to go in development, I'm also for using it in CI as this would bring the two testing environments closer together. 👍

@smsearcy
Copy link
Contributor Author

smsearcy commented Jan 9, 2019

FYI, I'm still working on updating Travis to use tox, I was just working on getting coverage working locally.

@smsearcy
Copy link
Contributor Author

smsearcy commented Jan 9, 2019

Ok, I think this is ready to for review. Travis is now using the tox environments for the different versions of Python and coverage. I did have an issue with local coverage reports that was solved by removing a stale __pycache__ folder.

I think that as a library the dependencies in requirements.txt and the tox are probably better suited to be test/dev extras in setup.py but I think that might be better cleaned up in a separate PR.

Copy link
Collaborator

@bbc2 bbc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Being able to run tests on various versions of Python, locally and easily, is awesome.

I'm afraid there is a conflict with master. Could you rebase and resolve it? It would be good to also squash the commits together in one commit to simplify the git history.

… installed version.

Added tox to run test suite against multiple versions of Python (with coverage) and run flake8.
Updated Travis CI to use tox as well.
Updated documentation about running tests.
@smsearcy
Copy link
Contributor Author

Apologies, I've been very busy lately but I finally got around to cleaning up this PR. Please let me know if there is anything else you would like to see.

@bbc2
Copy link
Collaborator

bbc2 commented Feb 13, 2019

Thank you for this work. I'm merging this!

@bbc2 bbc2 merged commit b881091 into theskumar:master Feb 13, 2019
@smsearcy smsearcy deleted the src-reorg branch February 14, 2019 22:22
@smsearcy smsearcy mentioned this pull request Feb 14, 2019
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

Successfully merging this pull request may close these issues.

6 participants