Open nfantone opened 9 years ago
Hi Take a look at the configuration examples. The tests runner is an addition to the package from one of our users, I am not that familiar with it myself as I always use the command line to run tests as I am really comfortable with the terminal.
Hi, @DamnWidget. I did take a look at the examples. None of them seemed very useful, honestly. They show samples for running tests using Twisted, Django and unittest, which aren't my case (and, also, do not correspond with the default setup).
Any ideas? Could you, perhaps, point me to a sample project actually using Anaconda to run tests locally, that I could take a look at?
What happens if you run the "Run full project tests suite"?
At first, without adding anything new to my sublime-project
file, running Run project tests ended correctly, but didn't find any tests to run.
Setting the "test_project_path"
property to my project's root directory, made it work ok from within Anaconda.
.......
----------------------------------------------------------------------
Ran 7 tests in 0.051s
OK
[Finished in 0.2s]
I feel this should be reflected somewhere in the documentation. "test_project_path"
is a mandatory configuration property if you intend to run this command.
Still no luck with Current File Tests, though.
The test runner is creating a module path from your project root to your current file and passing that to your test command, (hence the periods in the filename).
Next question is, is your test module import
able from your project root?
Isn't that what nose
is for? Discovering tests and module imports?
If the functionality is running current file tests, why isn't Anaconda feeding to whatever command line I have configured in "test_command"
the path of the currently displayed file?
The problem here is that this feature has been designed most likely by one user to cover their own use case for testing, which happens to be with module paths.
Maybe you'd like to contribute some code that returns the test file path instead with a way to switch back and forth between these two modes?
Ok. I'll try to make a PR as soon as I'm able to. Could you, please, give some pointers as where to be looking at to add this changes?
Also, if I were to make the current settings work with my project (that is, running tests with module paths), how should I go about it?
My layout looks like this:
sql-tools/
sql-tools/
sqltools.py
test/
test_sqltools.py
The changes would have to go around this line in this file.
Looking at that function, the module path is built from the test_root
to the current file. Looking up where test_root
is set here it appears to be an undocumented config option named test_root
that defaults to the window's current folder.
So why not try setting test_root
in your project settings to ./sql_tools/
and seeing what happens. You can check which command the test runner tries to run by looking at the ST console Ctrl + `.
@nfantone Run into this same problem today and solved it by doing what I suggested above.
What I've found out:
test_root
defaults to the first open project folder, but you can override it in your .project-settings
. This will be the working directory from which your test runner will be executed. CAVEAT: This must be an absolute system path, not relative to your project root.test_project_path
is used only when your run all project tests and gets added to the end of your test runner command in that instance.So you will be able to make your scenario work by doing this:
test_project_path
test_root
to /full/path/to/project/sql-tools/
, assuming sqltool.tests.test_sqltools
is import
able from this directory.Comment: This is a rather convoluted situation that deserves better documentation and perhaps even a rethinking of how to cover most use cases in a intuitive way.
I'm really perplexed here. I'm struggling to understand what is Anaconda trying to do when running Current File Tests, with default settings, using
nose
.I have a dead simple
tests/test_sqlutils.py
file, with one empty test that just doespass
.Running it form the command line is pretty straight forward and works as expected:
However, executing things from within Anaconda ends in failure (
Ctrl
+Shift
+p
>Run Current File Tests
).What is going on here? What's
sql-tools.tests.test_sqlutils
? From the source code, I can see that this this line effectively replaces/
for.
in the test file path. Why isn't the shell commandnosetests sql-tools/tests/test_sqlutils.py
? That would actually work from the root of the project.Do I need to restructure my tests? Anything to configure? This is rather obscure.