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

testmon doesn't track sources in venv directory #206

Open
emavgl opened this issue Feb 13, 2023 · 4 comments
Open

testmon doesn't track sources in venv directory #206

emavgl opened this issue Feb 13, 2023 · 4 comments

Comments

@emavgl
Copy link

emavgl commented Feb 13, 2023

Hi everyone. I am testing testmon for the project in my company and after having some issues, I am trying to create a simple use case to help identifying the problem and maybe also with the debugging.

I started creating a simple code:

# tests/test_gold_app.py

class MyCode:
    def add(self, a, b):
        return a + b


class TestCode:
    def test_mock(self):
        assert MyCode().add(1, 3) == 4

I then run testmon once

python -m pytest tests/test_gold_app.py --testmon

and tests are collected and executed fine.

Then, I do a small change in the MyCode class.

class MyCode:
    def add(self, a, b):
        return a + b + 1 # this was changed
        
class TestCode:
    def test_mock(self):
        assert MyCode().add(1, 3) == 4 # this should fail, but the test does not run again

and this time no tests is running.

========================================== test session starts ===========================================
platform darwin -- Python 3.9.6, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
testmon: changed files: 0, skipping collection of 1 files, environment: default
rootdir: /Users/emv/repos/test-testmon
plugins: pspec-0.0.4, xdist-2.3.0, testmon-1.4.5, html-3.1.1, mock-3.6.1, html-reporter-0.2.9, metadata-2.0.4, forked-1.6.0
collected 1 item / 1 deselected  

What I expect, is that since the code of the method add has changed. Also the test test_mock has to run again. Am I right?

Same thing, if I change the test only, maybe changing the assertion, like this:

class MyCode:
    def add(self, a, b):
        return a + b


class TestGoldApp:
    def test_mock(self):
        assert MyCode().add(1, 3) == 5

test_mock should run again, but it does not.

Am I missing something? Thank you!

@pokopt
Copy link
Collaborator

pokopt commented Feb 15, 2023

Hi @emavgl, thanks for your effort to provide example that didn't work for you! You are right this is not expected behavior of testmon - it definitely should recognize changes you described. And it does in my environment. We will investigate deeper and maybe will come back for some additional info.

@emavgl
Copy link
Author

emavgl commented Feb 15, 2023

Hi @pokopt, thank you for checking my issue. In case you need something, I would be happy to help you with the investigation

@pokopt
Copy link
Collaborator

pokopt commented Feb 15, 2023

Hi @emavgl. We are able to reproduce this behavior if 'tests' directory is placed inside your virtual environment directory. Is it your case as well? Is your virtual environment created in /Users/emv/repos/test-testmon ? If so, there is workaround to create virtual environment in separate directory (e.g. /Users/emv/repos/test-testmon/venv) and testmon should run just fine. However we will try to provide real fix for this situation.

@emavgl
Copy link
Author

emavgl commented Feb 15, 2023

Great catch! It is indeed my case. I tried with the workaround and it now works as expected. I think it is a bug that needs to be addressed, even if in my case, it is not that problematic. I will continue with other investigations then :)

@tarpas tarpas changed the title Testmon does not detect simple change testmon doesn't track sources in venv directory Feb 15, 2023
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

2 participants