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

monkeytype run manage.py test doesn't produce sqllite file #34

Closed
nsillik opened this issue Dec 22, 2017 · 10 comments
Closed

monkeytype run manage.py test doesn't produce sqllite file #34

nsillik opened this issue Dec 22, 2017 · 10 comments

Comments

@nsillik
Copy link

nsillik commented Dec 22, 2017

I've run monkeytype run manage.py test in my django project after pip install monkeytype (inside of a virtual env) and I'm not seeing any output of the sqllite file described in the README.

Running monkeytype stub for any of my modules doesn't work either. If there's something different that I have to do for django tests, let's add that to the README. Otherwise, am I missing something?

@nsillik
Copy link
Author

nsillik commented Dec 22, 2017

Sorry, to add more detail I'm running this on: Django==1.11.7 and MonkeyType==17.12.2.

@carljm
Copy link
Contributor

carljm commented Dec 22, 2017

Do you get an error or any output at all from monkeytype run?

@carljm
Copy link
Contributor

carljm commented Dec 22, 2017

Closing for now since there's not enough information here to do any debugging; will reopen if we get full paste of shell session, with all output.

Most likely issue is that you are hitting #28.

@carljm carljm closed this as completed Dec 22, 2017
@nsillik
Copy link
Author

nsillik commented Dec 22, 2017

Other than some warnings generated by my tests, there's no output that seems like it's from monkeytype:

» monkeytype run manage.py test
Creating test database for alias 'default'...
System check identified some issues:

WARNINGS:
?: (django_mysql.W003) The character set is not utf8mb4 for database connection 'default'
	HINT: The default 'utf8' character set does not include support for all Unicode characters. It's strongly recommended you move to use 'utf8mb4'. See: https://django-mysql.readthedocs.io/en/latest/checks.html#django-mysql-w003-utf8mb4

System check identified 1 issue (0 silenced).
............/Users/nsillik/Development/mado/mado-api/mado_api/util/paginator.py:9: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'mado_api.device.models.DeviceConnection'> QuerySet.
  paginator = Paginator(qs, numResults)
..................................................................
----------------------------------------------------------------------
Ran 78 tests in 10.033s

OK
Destroying test database for alias 'default'...

@carljm
Copy link
Contributor

carljm commented Dec 22, 2017

That's odd. Do you have a monkeytype_config.py? Or have you set the MT_DB_PATH environment variable?

@carljm carljm reopened this Dec 22, 2017
@mandx
Copy link

mandx commented Dec 22, 2017

The test runner could affect this; for example, when using --parallel with the default test runner, and parallel test execution is enabled by default in Django 1.11:

--parallel [N]

Runs tests in separate parallel processes. Since modern processors have multiple cores, this allows running tests significantly faster.

By default --parallel runs one process per core according to multiprocessing.cpu_count(). You can adjust the number of processes either by providing it as the option’s value, e.g. --parallel=4, or by setting the DJANGO_TEST_PROCESSES > environment variable.

If my theory is correct, then MonkeyType whould be tracing just the main test supervisor process, which is (I guess) Django-only code.

@nsillik Can you try running the tests with just one process?

@nsillik
Copy link
Author

nsillik commented Dec 22, 2017

@mandx monkeytype run ./manage.py test --parallel 1 generated a sqllite file!

I'm still not able to generate stubs, but I think that's a separate issue.

@carljm I do not have a monkeytype_config.py or MT_DB_PATH variable set.

I'm going to close this while I see what the issue with stub generation is. Thanks for your help!

@nsillik nsillik closed this as completed Dec 22, 2017
@carljm
Copy link
Contributor

carljm commented Dec 22, 2017

Thanks for identifying the problem, @mandx ! I'll add an entry about this issue to the FAQ.

@mandx
Copy link

mandx commented Dec 22, 2017

@carljm I came back to say just that, a note about this "gotcha" would be really appreciated by newcomers, specially because Django has this behavior enabled by default, and most likely people will try out this tool by running unit tests in a local development environment.

BTW, thanks for opensourcing this!

@carljm
Copy link
Contributor

carljm commented Dec 22, 2017

FAQ entry added: http://monkeytype.readthedocs.io/en/latest/faq.html

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