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

[WIP] Write unit tests for the functions in utils.py #36

Closed
wants to merge 1 commit into from

Conversation

skulltech
Copy link
Contributor

This is a WIP as of now. Made pull request to get input from project maintainers. @marco-c

@@ -0,0 +1,15 @@
import sys
import os
sys.path.append(os.path.dirpath(os.path.realpath(__file__)) + '/../')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this an acceptable way to import the utils.py module from the outer directory? Seems like a hack to me, but this is what I got after some stackoverflow searches.

Copy link
Owner

Choose a reason for hiding this comment

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

I hadn't seen this comment 😄
I've replied at #36 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

@skulltech @marco-c I think its always better to avoid system calls. :) Once the structure of the directory is set, it will be easier. OOP structure favours imports with ease.

Can I structure the whole network.py into a nice class with appropriate functions ? What do you think ?

Copy link
Owner

Choose a reason for hiding this comment

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

@skulltech @marco-c I think its always better to avoid system calls. :) Once the structure of the directory is set, it will be easier. OOP structure favours imports with ease.

For now, we are leaning towards moving the network.py and utils.py modules into a autowebcompat directory and leaving the scripts (which are never used as modules) in the top-level directory. Discussion at #36 (review).

Can I structure the whole network.py into a nice class with appropriate functions ? What do you think ?

Sounds good to me, this should happen regardless of the directory structure.

Copy link
Contributor Author

@skulltech skulltech left a comment

Choose a reason for hiding this comment

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

Let me know what do you think of the import style. Seems like a hack to me.

@@ -0,0 +1,15 @@
import sys
import os
sys.path.append(os.path.dirpath(os.path.realpath(__file__)) + '/../')
Copy link
Owner

Choose a reason for hiding this comment

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

Can we avoid this? Maybe we can restructure the project like the first example at https://docs.pytest.org/en/latest/goodpractices.html#tests-outside-application-code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first example's directory structure looks good. If we rearrange our project like that, will we able to import the project modules directly? like

from autowebcompat import utils

Copy link
Owner

Choose a reason for hiding this comment

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

I think so, if you execute python3 -m pytest or PYTHONPATH=. pytest.

Instead of restructuring, we can also run PYTHONPATH=.. pytest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think restructuring will also help us in the long run. So better to just do it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not totally sure because the source files are executable scripts rather than modules that you import.
Only network.py and utils.py are actually modules.
Maybe we can restructure putting network.py and utils.py in a autowebcompat directory, but keeping the other scripts where they are.

@skulltech
Copy link
Contributor Author

Created issue #37 in reference to this.

@marco-c
Copy link
Owner

marco-c commented Feb 15, 2018

Hey @skulltech, since #6 is a "good first issue", I'll close this and let someone without experience with the project take it.

@marco-c marco-c closed this Feb 15, 2018
@propr
Copy link

propr bot commented Feb 15, 2018

Please provide your feedback on this pull request here.

Privacy statement: We don't store any personal information such as your email address or name. We ask for GitHub authentication as an anonymous identifier to account for duplicate feedback entries and to see people specific preferences.

marxmit7 pushed a commit to marxmit7/autowebcompat that referenced this pull request Jan 18, 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.

None yet

3 participants