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

Set path for tests/ directory #19

Open
Konrad-Ziarko opened this issue Feb 1, 2019 · 7 comments
Open

Set path for tests/ directory #19

Konrad-Ziarko opened this issue Feb 1, 2019 · 7 comments

Comments

@Konrad-Ziarko
Copy link

Hi,
Great package!
Am I missing way to set path for generated tests/ directory, or is it not implemented?
Auger creates whole full path instead of just tests/ subdirectory - like this

@NextDesign1
Copy link
Collaborator

Do you have a short test case that I can take a look at?

@Konrad-Ziarko
Copy link
Author

Konrad-Ziarko commented Feb 9, 2019

def testfun_test():
    return 0

if __name__ == '__main__':
    import auger
    funs = [f for f in dir() if f.startswith('testfun')]
    module = sys.modules[__name__]
    with auger.magic(funs):
        for f in funs:
            getattr(module, f)()

@NextDesign1
Copy link
Collaborator

NextDesign1 commented Feb 9, 2019

And this snippet was producing the issue? I couldn't reproduce it on my end when running it in the root of a fresh virtualenv.

$ ls
bin    		include		issue19.py     	lib

$ cat issue19.py
import sys

def testfun_test():
    return 0

if __name__ == '__main__':
    import auger
    funs = [f for f in dir() if f.startswith('testfun')]
    module = sys.modules[__name__]
    with auger.magic(funs):
        for f in funs:
            getattr(module, f)()

$ python issue19.py
Auger: generated test: tests/test_Issue19.py

$ ls ./tests
test_Issue19.py

$ cat ./tests/test_Issue19.py
import __main__
import issue19
import sys
import unittest


class Issue19Test(unittest.TestCase):
    def test_testfun_test(self):
        self.assertEqual(
            __main__.testfun_test(),
            0
        )


if __name__ == "__main__":
    unittest.main()

@Konrad-Ziarko
Copy link
Author

Ok, you are right, if I start script via terminal it creates test in tests/ directory.
Problem shows up within PyCharm. Must be wroking directory in env setup in PyCharm.
but
From terminal, in that folder os.getcwd() and PyCharm Working Directory points to same location.

@NextDesign1
Copy link
Collaborator

Could you try printing out funs and module inside pycharm and in a separate terminal?

@Konrad-Ziarko
Copy link
Author

From PyCharm:
module: <module 'main' from '/home/konrad/PycharmProjects/PyPractice/pypractice/tricks_n_tips/string_formatting/snippets.py'>
funs: ['testfun_test']

From terminal:
module: <module 'main' from 'snippets.py'>
funs: ['testfun_test']

So it definitely took module path and added it to produce tests.
One way to avoid it would be to import that module from another script.
Another one would be to start script from terminal.

@Konrad-Ziarko
Copy link
Author

It still would be nice to be possible to set arbitrary path for produced tests

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

No branches or pull requests

2 participants