Code Monkey home page Code Monkey logo

nose-dep's People

Contributors

larry-dean avatar zitrax avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nose-dep's Issues

nosedep:NoseDep: cannot import name windows_support - setuptools 37

When I use python 2.7.14 and upgrade setuptools from 36.5 to 37

pip install nose
pip install nosedep
nosetests -V
python2.7/site-packages/nose/plugins/manager.py:395: RuntimeWarning: 
Unable to load plugin nosedep = nosedep:NoseDep: cannot import name windows_support 
 RuntimeWarning)
nosetests version 1.3.7

setuptools 36.5 or other nose plugin work well

nosedep dependencies not applied when running a directory of tests

Looking at one of the older issues, it appears the dependencies should work when running nosetests via selecting a starting directory as opposed to running the file directly. That seems to not be working. We use groups and 'tests' as starting points for running suites with nosetests.
Have you gotten this to work?
Here's the test:

import unittest
from nosedep import depends

# set path to common libraries

class display_node_list(unittest.TestCase):
    @depends(after='test_02')
    def test_01(self):
        print "\nTest 1"

    @depends(after='test_03')
    def test_02(self):
        print "\ntest 2"

    @depends(after='test_04')
    def test_03(self):
        print "\ntest 3"

    def test_04(self):
        # This test displays a list of the nodes, type and name
        print "\ntest 4"

Running the file dep_test.py directly:

(eh-ub16) hohene@lab17:~/sandbox-github/rackhd/eh-cit-nosedep/test/tests$ nosetests --exe -s -v  --with-nosedep api-cit/eh/dep_test.py
test_04 (eh.dep_test.display_node_list) ... 
test 4
ok
test_03 (eh.dep_test.display_node_list) ... 
test 3
ok
test_02 (eh.dep_test.display_node_list) ... 
test 2
ok
test_01 (eh.dep_test.display_node_list) ... 
Test 1
ok

----------------------------------------------------------------------
Ran 4 tests in 0.002s

OK

Running by the directory:

(eh-ub16) hohene@lab17:~/sandbox-github/rackhd/eh-cit-nosedep/test/tests$ nosetests --exe -s -v  --with-nosedep api-cit/eh
test_01 (eh.dep_test.display_node_list) ... ERROR
test_02 (eh.dep_test.display_node_list) ... ERROR
test_03 (eh.dep_test.display_node_list) ... ERROR
test_04 (eh.dep_test.display_node_list) ... 
test 4
ok

======================================================================
ERROR: test_01 (eh.dep_test.display_node_list)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/emc/hohene/sandbox-github/rackhd/eh-cit-nosedep/test/env/eh-ub16/local/lib/python2.7/site-packages/nosedep.py", line 323, in error_test
    raise Exception(res)
Exception: Required test 'test_02' did not run (does it exist?)

======================================================================
ERROR: test_02 (eh.dep_test.display_node_list)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/emc/hohene/sandbox-github/rackhd/eh-cit-nosedep/test/env/eh-ub16/local/lib/python2.7/site-packages/nosedep.py", line 323, in error_test
    raise Exception(res)
Exception: Required test 'test_03' did not run (does it exist?)

======================================================================
ERROR: test_03 (eh.dep_test.display_node_list)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/emc/hohene/sandbox-github/rackhd/eh-cit-nosedep/test/env/eh-ub16/local/lib/python2.7/site-packages/nosedep.py", line 323, in error_test
    raise Exception(res)
Exception: Required test 'test_04' did not run (does it exist?)

----------------------------------------------------------------------
Ran 4 tests in 0.004s

FAILED (errors=3)

collect-only incompatible with nosedep

nosetests -v -w ${test_subdir} --collect-only -s ./test.py:testClassName would be used to collect the names f the tests but not actually run them. It's useful for listing out generated test names using nose-parameterized

With nosedep, the following no longer just lists tests, but tries to execute them:

nosetests --with-nosedep -v -w ${test_subdir} --collect-only -s ./test.py:testClassName

This seems to be unexpected behavior: I would expect --collect-only to still only collect the names of tests.

nosetests fails to discover tests with nosedep enabled

I'm using nose 1.3.7 to run several tests, and I've just installed nose-dep 0.2 (nose and nosedep installed in a virtualenv).

I have not changed my tests yet to use @depends.

My directory layout is basically like this:

package/
    __init__.py
    some_code.py
    tests/
        foo/
            __init__.py
            test_package.py

If I do:

~/package$ export PYTHONPATH=~/package
~/package$ nosetests tests
....
Ran 10 tests in 10.000s

All my tests are run properly. But as soon as I add --with-nosedep:

~/package$ nosetests --with-nosedep tests
....
Ran 0 tests in 0.000s

The following also works

~/package$ nosetests tests/foo/test_package.py

But this:

~/package$ nosetests --with-nosedep tests/foo/test_package.py

I get:

Traceback (most recent call last):
  File "/home/user/package/venv/bin/nosetests", line 11, in <module>
    sys.exit(run_exit())
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nose/core.py", line 50, in run
    wrapper = self.config.plugins.prepareTest(test)
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nosedep.py", line 235, in prepareTest
    reraise(t, v, tb)
  File "/home/user/package/venv/local/lib/python2.7/site-packages/nosedep.py", line 230, in prepareTest
    all_tests[tt.test.test.__name__] = tt
AttributeError: 'Failure' object has no attribute 'test' - Due to: Failure: OSError (No such file /home/user/package/tests/foo/test_package)

Besides the somehow convoluted project layout (can't help it, not my project), am I missing something or doing it wrong? Or is this an issue on nosedep?

Thanks for sharing your work, looking forward to be able to use it! :-D

Dekorator "depends" doesn't sets dependency into tests.

Hello, please help me with my issue. I tried find framework for making dependency between tests, and I found your, but when I try to use decorator @Depends my tests run in the alphabetic order.

For example:

from nosedep import depends

def test_a():
print ("Success test a")

@Depends(before=test_a) or (before='test_a') or (before="test_a")
def test_b():
print ("Success test b")

Also I tried @after, and used "priority", it didn't help.

`nosetests --with-nosedep <module>` runs much more tests than asked for

yann@yantop:omaha (wip/tori-ai<>)$ nosetests3
.........................................................................................................................
----------------------------------------------------------------------
Ran 121 tests in 5.007s

OK
$ nosetests3 Omaha.test
.......................................................................
----------------------------------------------------------------------
Ran 71 tests in 4.849s

OK
$ nosetests3 Omaha.test.test_torishogi
...
----------------------------------------------------------------------
Ran 3 tests in 0.523s

OK
$ nosetests3 --with-nosedep Omaha.test.test_torishogi
...........................................................................
----------------------------------------------------------------------
Ran 75 tests in 4.894s

OK

For now the only use of nosedep is in Omaha/test/test_torishogi.py:

@depends(after=test_loadpgn)
def test_undoredo():

See below the diff between the last 2 runs when using -v. You'll notice that the nosedep run does not include all of the tests of its supermodule, but also that some of those tests are run several times, and that the order of execution differs from the standard nosetests order, even for tests which do not make use of nosedep.

$ diff -u /tmp/nodeps-omaha /tmp/deps-tori
--- /tmp/nodeps-omaha   2020-08-04 19:41:46.467510379 +0200
+++ /tmp/deps-tori      2020-08-04 19:40:54.255121993 +0200
@@ -1,21 +1,33 @@
 Omaha.test.test_checkers.test_checkers ... ok
 Omaha.test.test_chess.test_chess ... ok
 Omaha.test.test_chess.test_loadpgn ... ok
-Omaha.test.test_chess5.test.test_enpassant ... ok
-Omaha.test.test_chess5.test.test_enpassant_delayed ... ok
-Omaha.test.test_chess5.test.test_enpassant_nonboost ... ok
-Omaha.test.test_chess5.test.test_pawn_check ... ok
-Omaha.test.test_chess5.test.test_undo_promotion ... ok
 Omaha.test.test_glinski.test00_hexbent_notation_a1.test_backnforth ... ok
 Omaha.test.test_glinski.test00_hexbent_notation_a6.test_backnforth ... ok
-Omaha.test.test_glinski.test00_hexbent_notation_f1.test_backnforth ... ok
 Omaha.test.test_glinski.test00_hexbent_notation_f11.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_f1.test_backnforth ... ok
 Omaha.test.test_glinski.test00_hexbent_notation_l1.test_backnforth ... ok
 Omaha.test.test_glinski.test00_hexbent_notation_l6.test_backnforth ... ok
 Omaha.test.test_glinski.test10_glinski ... ok
 Omaha.test.test_go.test_go ... ok 
-Omaha.test.test_go.test_nonstandardgo ... ok
 Omaha.test.test_go.test_loadsgf ... ok
+Omaha.test.test_go.test_nonstandardgo ... ok
+Omaha.test.test_minishogi.test.test_minishogi ... ok
+Omaha.test.test_minishogi.test.test_undo ... ok
+Omaha.test.test_minishogi.test_handicap ... ok
+Omaha.test.test_shogi.test_loadpgn ... ok
+Omaha.test.test_shoshogi.test_prince ... ok
+Omaha.test.test_shoshogi.test_shoshogi ... ok
+Omaha.test.test_torishogi.test_play.test_torishogi ... ok
+Omaha.test.test_torishogi.test_loadpgn ... ok
+Omaha.test.test_torishogi.test_undoredo ... ok
+Omaha.test.test_minishogi.test.test_minishogi ... ok
+Omaha.test.test_minishogi.test.test_undo ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_a1.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_a6.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_f1.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_f11.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_l1.test_backnforth ... ok
+Omaha.test.test_glinski.test00_hexbent_notation_l6.test_backnforth ... ok
 Omaha.test.test_import.test_Apps.test_QtLauncher ... ok
 Omaha.test.test_import.test_Apps.test_QtPlay ... ok
 Omaha.test.test_import.test_CheckersPlayerDrivers.test_ManualEntry ... ok
@@ -60,17 +72,9 @@
 Omaha.test.test_import.test_ShogiPlayerDrivers.test_Multiplexer ... ok
 Omaha.test.test_import.test_ShogiPlayerDrivers.test_Stdin ... ok
 Omaha.test.test_import.test_ShogiPlayerDrivers.test_XShogi ... ok
-Omaha.test.test_minishogi.test.test_minishogi ... ok
-Omaha.test.test_minishogi.test.test_undo ... ok
-Omaha.test.test_minishogi.test_handicap ... ok
-Omaha.test.test_shogi.test_loadpgn ... ok
-Omaha.test.test_shoshogi.test_shoshogi ... ok
-Omaha.test.test_shoshogi.test_prince ... ok
 Omaha.test.test_torishogi.test_play.test_torishogi ... ok
-Omaha.test.test_torishogi.test_loadpgn ... ok
-Omaha.test.test_torishogi.test_undoredo ... ok

 ----------------------------------------------------------------------
-Ran 71 tests in 4.914s
+Ran 75 tests in 4.940s

Strict roles

Could be nice to be able to mark a test as "smoke" or similar which would cause everything to be skipped if it's not ok.

Support SkipTest

There seem to be an issue when specifying explicitly to run a test that raises SkipTest.

Needs to be investigated, but I would assume that the test should still be reported as skipped, that was not the case for the test I tried.

Tests are not run when implementing nosetests on a directory of tests

Hi, I am currently using this package since I need ordering of tests. Tests file is getting passed when nosetests is implemented individually on the file with the "--with-nosedep" dependency. But when ran against a directory of files no tests are running and it ends with a success response. I am using nosedep == 0.7 version.

So basically
nosetests -v --with-nosedep /path/to/directory/test.py -> runs successfully
nosetests -v --with-nosedep -w /path/to/directory -> does not run any test and ends with success response

How to resolve this issue

Note : Directory of files contains other test files where nosedep dependencies are not used

Can't load '.'

Currently when trying to load tests from name '.' we had a platform difference since it cause use of absolute path which in turn cause us to split on ':' on windows while linux does not have a ':' in the path.

This is currently worked around / disabled by returning an empty test suite if '.' is used.

Obviously this should be handled better by actually loading tests properly.

The workaround was added in 2abbf4e.

nosedep causes all ancestor unites classes to be executed

When testing #12, ran into another issue:

(based on decorated_functional_dep_skip, edited similar to #12, all depends removed, two descendent classes added)

from unittest import SkipTest, TestCase
  
class decorated_functional_dep_skip(TestCase):
    def test_dfds_a(self):
        pass

    def test_dfds_b(self):
        pass

    def test_dfds_c(self):
        pass

    def test_dfds_d(self):
        pass

    def test_dfds_e(self):
        pass

    def test_dfds_f(self):
        pass

class descendent1(decorated_functional_dep_skip):
    pass

class descendent2(descendent1):
    pass

Run with the following shows only 6 unittests as expected:

nosetests --no-byte-compile --with-xunit -v -s ./testfail.py:descendent1

Run with the --with-nosedep option, and now all ancestor and descendent classes (6 x 3 == 18 tests) also executed:

nosetests --no-byte-compile --with-nosedep --with-xunit -v -s ./testfail.py:descendent1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.