Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

test.py doesn't run #58

Open
KirkEasterson opened this issue Nov 27, 2020 · 1 comment
Open

test.py doesn't run #58

KirkEasterson opened this issue Nov 27, 2020 · 1 comment

Comments

@KirkEasterson
Copy link

OS: Kubuntu 20.04

To recreate:

git clone https://github.com/nanomsg/nnpy.git
cd nnpy/nnpy
python tests.py

This produces the output::

Traceback (most recent call last):
  File "tests.py", line 2, in <module>
    import filecmp, nnpy, sys, unittest
  File "build/bdist.linux-x86_64/egg/nnpy/__init__.py", line 2, in <module>
    from _nnpy import ffi, lib as nanomsg
  File "build/bdist.linux-x86_64/egg/_nnpy.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/_nnpy.py", line 3, in __bootstrap__
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 36, in <module>
    import email.parser
  File "/usr/lib/python2.7/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser
  File "/usr/lib/python2.7/email/feedparser.py", line 27, in <module>
    from email import message
  File "/usr/lib/python2.7/email/message.py", line 16, in <module>
    import email.charset
  File "/usr/lib/python2.7/email/charset.py", line 13, in <module>
    import email.base64mime
  File "/usr/lib/python2.7/email/base64mime.py", line 40, in <module>
    from email.utils import fix_eols
  File "/usr/lib/python2.7/email/utils.py", line 28, in <module>
    import socket
  File "/home/nnpy/nnpy/socket.py", line 1, in <module>
    from . import errors, ffi, nanomsg
ValueError: Attempted relative import in non-package

This is because the directory that the tests are being run in takes precedence for imports and class declarations. This can be observed in the lines:

...
  File "/usr/lib/python2.7/email/utils.py", line 28, in <module>
    import socket
...

There are three options:

  1. Move test,py to nnpy/
  2. Create an nnpy/test/ directory and move it there
  3. Create an nnpy/nnpy/test/ directory and move it there

I think option 3 is preferable

@KirkEasterson KirkEasterson changed the title Tests don't run test.py doesn't run Nov 27, 2020
@djc
Copy link
Member

djc commented Nov 27, 2020

Have you tried running python setup.py test from the top-level directory, instead?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants