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

Nose is obsolete #1031

Open
LourensVeen opened this issue Feb 5, 2024 · 9 comments
Open

Nose is obsolete #1031

LourensVeen opened this issue Feb 5, 2024 · 9 comments

Comments

@LourensVeen
Copy link
Collaborator

Describe the bug
The tutorial at https://amuse.readthedocs.io/en/latest/tutorial/c_code.html guides the user to run the tests for the package using nosetests. This command is from the nose package, which is unmaintained and obsolete and doesn't work on recent Python versions. It's been succeeded by nose2, which at least for the trivial example tests seems to do work.

To Reproduce

amusifier --type=c --mode=dir NearestNeighbor
cd nearestneighbor
make
pip install nose
nosetests

Expected behavior

.
----------------------------------------------------------------------
Ran 1 test in 0.648s

OK

Logs

Traceback (most recent call last):
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/bin/nosetests", line 8, in <module>
    sys.exit(run_exit())
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/core.py", line 118, in __init__
    unittest.TestProgram.__init__(
  File "/usr/lib/python3.10/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/core.py", line 179, in parseArgs
    self.createTests()
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/core.py", line 193, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames)
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/loader.py", line 481, in loadTestsFromNames
    return unittest.TestLoader.loadTestsFromNames(self, names, module)
  File "/usr/lib/python3.10/unittest/loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.10/unittest/loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/loader.py", line 431, in loadTestsFromName
    return self.loadTestsFromModule(
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/loader.py", line 354, in loadTestsFromModule
    tests.extend(self.loadTestsFromDir(module_path))
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/loader.py", line 195, in loadTestsFromDir
    yield self.suiteClass(
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/suite.py", line 423, in __call__
    tests = self.wrapTests(tests)
  File "/home/lourens/NLeSC/projects/ReDiTSAp/software/Amuse-env/lib/python3.10/site-packages/nose/suite.py", line 541, in wrapTests
    if isinstance(tests, collections.Callable) or isinstance(tests, unittest.TestSuite):
AttributeError: module 'collections' has no attribute 'Callable'

Environment (please complete the following information):
Kubuntu 22.04
GCC 11.4.0

Additional context
This works at least for this trivial test:

pip uninstall nosetests
pip install nose2
nose2
@rieder
Copy link
Member

rieder commented Feb 5, 2024

We've actually retired nose for testing in favour of pytest, but clearly this change hasn't propagated to all the documentation yet.

@rieder
Copy link
Member

rieder commented Feb 5, 2024

see #196

@rieder rieder added documentation and removed bug labels Feb 5, 2024
@LourensVeen
Copy link
Collaborator Author

LourensVeen commented Feb 5, 2024

Ah, I can confirm that pytest also seems to run the tests, so it's indeed just a documentation issue. Farther down it suggests running pysetest, which I guess is some weird hybrid of the two 😄.

@LourensVeen
Copy link
Collaborator Author

I might as well add another issue about the same page here: the test doesn't work because instance.find_nearest_neighbors(x,y,z) returns only 3 values, not the n0, n1, n2, error we are expecting. Possibly the API changed?

If I remove those checks, then it still fails, because of an off-by-one indexing error. It seems like the test expects the indexes returned in n0 to be 1-based, while the C++ code returns 0-based indexes. I guess this was copy-pasted from the Fortran side maybe? Does AMUSE have a standard for whether indexes are 0- or 1-based?

@LourensVeen
Copy link
Collaborator Author

LourensVeen commented Feb 5, 2024

In interface.py I need to write

    def define_methods(self, handler):
        handler.add_method(
                "find_nearest_neighbors",
                (
                    generic_unit_system.length,
                    generic_unit_system.length,
                    generic_unit_system.length
                ),
                (
                    handler.INDEX,
                    handler.INDEX,
                    handler.INDEX
                )
        )

without the additional handler.ERROR_CODE to get test3 to work. I'm not sure however if error handling has been automated completely and manually declaring that output is no longer necessary, or if removing it disables error handling.

Oh, and the test file needs a from amuse.units import generic_unit_system to get that symbol to resolve.

Copy link

stale bot commented Apr 10, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 28 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issues that have been around for a while without updates label Apr 10, 2024
@LourensVeen
Copy link
Collaborator Author

Let's keep this open and consider it a documentation issue. I've been working on getting tests to run in combination with the new packaging work, so that's a separate thing, and then there's another potential separate project in removing the custom infrastructure from the tests and use the facilities that pytest offers. I've made #1044 for the latter.

@stale stale bot closed this as completed May 10, 2024
@rieder rieder removed the stale Issues that have been around for a while without updates label May 10, 2024
@rieder rieder reopened this May 10, 2024
@LourensVeen
Copy link
Collaborator Author

Ah, thanks. I guess you need to remove stale to keep it from closing, and add keep-open to keep it from getting marked as stale?

@rieder
Copy link
Member

rieder commented May 10, 2024 via email

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