schollii / pypubsub

A Python publish-subcribe library (moved here from SourceForge.net where I had it for many years)
189 stars 29 forks source link

policies and py2and3 imports (3.3.0) #34

Closed TheChymera closed 5 years ago

TheChymera commented 5 years ago

I am having issues while trying to run the tests with some imports, in particular this bit (in pypubsub/src/pubsub/core/topicdefnprovider.py ) :

from .. import (
        policies,
        py2and3
)

any idea where these modules should be coming from?

schollii commented 5 years ago

Are they missing from your distro? Where did you download from?

TheChymera commented 5 years ago

where die I download pypubsub? I tried https://github.com/schollii/pypubsub/archive/v3.3.0.zip as suggested in an earlier issue, and the files are not included. Are they developed as part of a different package?

schollii commented 5 years ago

Have a look at https://github.com/schollii/pypubsub/releases/tag/v3.3.0 (the Attention notice), and let me know if that allows you to solve your problem.

BTW in what earlier issue do I suggest to download https://github.com/schollii/pypubsub/archive/v3.3.0.zip (which the Attention notice says not to do!)?

TheChymera commented 5 years ago

@schollii I am still getting issues with the imports using the data from pypi:

 * python2_7: running distutils-r1_run_phase python_test
Failure: RuntimeError (Should not import this directly, used by pubsub.core if applicable) ... ERROR
Failure: RuntimeError (Should not import this directly, used by pubsub.core if applicable) ... ERROR

======================================================================
ERROR: Failure: RuntimeError (Should not import this directly, used by pubsub.core if applicable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/PyPubSub-3.3.0-python2_7/lib/pubsub/core/arg1/__init__.py", line 16, in <module>
    raise RuntimeError(msg)
RuntimeError: Should not import this directly, used by pubsub.core if applicable

======================================================================
ERROR: Failure: RuntimeError (Should not import this directly, used by pubsub.core if applicable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/PyPubSub-3.3.0-python2_7/lib/pubsub/core/kwargs/__init__.py", line 16, in <module>
    raise RuntimeError(msg)
RuntimeError: Should not import this directly, used by pubsub.core if applicable

----------------------------------------------------------------------
Ran 2 tests in 0.021s
schollii commented 5 years ago

What's the command you ran? Note we can also troubleshoot on gitter/pypubsub

TheChymera commented 5 years ago

nosetests -v is what I ran

schollii commented 5 years ago

I'm going to have to dig; basically I created the v3.3 on sourceforge and later migrated to github, and I think the tag I created for that release is incorrect, it doesn't have the right source. OTOH the zip on pypi has the right source, but does not have the tests etc.

schollii commented 5 years ago

OK so try this one: https://github.com/schollii/pypubsub/tree/624d7496f47664c136a4139ac76a3589d61e7986.

For the record, this is a snapshot of the code I brought into github from my SourceForge, it is on branch 3.3.0. It looks like later commits on that branch involved mods that actually ended up on the 4.0 branch, so it's a bit messed up. I'm going to have to see if I can fix that, but meanwhile, hopefully the above snapshot (which has the complete source -- tests and orig policies.py file etc) has a runnable test suite (don't have time to try just now).

I gather you are running this with Python 2.7?

TheChymera commented 5 years ago

Hm the tests still fail, albeit with a different message:

>>> Test phase: dev-python/pypubsub-3.3.0
 * python2_7: running distutils-r1_run_phase python_test
Failure: SyntaxError (invalid syntax (publisher.py, line 28)) ... ERROR
Failure: SyntaxError (invalid syntax (publisher.py, line 28)) ... ERROR

======================================================================
ERROR: Failure: SyntaxError (invalid syntax (publisher.py, line 28))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/core/__init__.py", line 10, in <module>
    from .publisher import Publisher
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/core/publisher.py", line 28
    def __init__(self, treeConfig: TreeConfig = None):
                                 ^
SyntaxError: invalid syntax

======================================================================
ERROR: Failure: SyntaxError (invalid syntax (publisher.py, line 28))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/utils/__init__.py", line 11, in <module>
    from .topictreeprinter import printTreeDocs
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/utils/topictreeprinter.py", line 10, in <module>
    from ..core.topictreetraverser import (ITopicTreeVisitor, TopicTreeTraverser)
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/core/__init__.py", line 10, in <module>
    from .publisher import Publisher
  File "/var/tmp/portage/dev-python/pypubsub-3.3.0/work/pypubsub-624d7496f47664c136a4139ac76a3589d61e7986-python2_7/lib/pubsub/core/publisher.py", line 28
    def __init__(self, treeConfig: TreeConfig = None):
                                 ^
SyntaxError: invalid syntax

----------------------------------------------------------------------
Ran 2 tests in 0.004s

Is it possible that python 2 support is broken? I am looking to package this version specifically because I want to offer users of my distribution (Gentoo) the alternative of using a python2-compatible version.

Conversely, when I drop python2 support, the test suite passes, but only because no tests are exacuted as part of it. Any ideas about this?

schollii commented 5 years ago

Looks like I must have made some Python-3 specific changes as part of migration to github. What you are seeing is an annotation, which are not supported in Python 2. I'm really not keen on pypubsub 3.3 being used with python 3; python 3 users should use pypubsub 4.x. Is there anyway you could do that? Then we could create a pypubsub 3.4 which would be python 2.7 only, and you would install pypubsub 3.4 for users who use python 2.7, but pypubsub 4.4 for users who use python 3.x.

Meanwhile try editing out the obvious python3'isms like annotations, see if the tests will pass.

Reminder: Python 2.7 is at EOL so will no longer be supported only for another year, and many major libraries have migrated to python 3, and many are dropping support for python 2.x. This is how people and companies will bite the bullet and upgrade to python 3, when we stop providing libs that work on python 2.x.

TheChymera commented 5 years ago

python 3 users should use pypubsub 4.x. Is there anyway you could do that?

That is no problem, so I'm dropping python 3.* from this specific version.

Then we could create a pypubsub 3.4 which would be python 2.7 only

That sounds really great! Do you need any more specific feedback from my side?

Python 2.7 is at EOL so will no longer be supported only for another year

I am aware, so until at the earliest on the very day when upstream deprecates it, there is scarcely any reason for us to prevent users from using python2.7. Even beyond that, about 1500 of the packages we provide do not have py3.* support in upstream, so it doesn't look like pulling the plug anytime soon is feasible, in fact, projects dropping support for 2.7 is not narrowing the gap between usage of the two versions, but widening it.

schollii commented 5 years ago

@TheChymera :

TheChymera commented 5 years ago

@schollii sorry for the break, I gave this a try now, and it seems no tests get run:

>>> Test phase: dev-python/pypubsub-3.4.0
 * python2_7: running distutils-r1_run_phase python_test
============================================= test session starts ==============================================
platform linux2 -- Python 2.7.15, pytest-4.2.0, py-1.5.4, pluggy-0.8.1 -- /usr/bin/python2.7
cachedir: .pytest_cache
rootdir: /var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0-python2_7, inifile:
collecting ... collected 0 items

========================================== deprecated python version ===========================================
You are using Python 2.7.15, which will no longer be supported in pytest 5.0
For more information, please read:
  https://docs.pytest.org/en/latest/py27-py34-deprecation.html
========================================= no tests ran in 0.01 seconds =========================================

I am trying to run them with pytest -vv, should I use something else?

schollii commented 5 years ago

It works here. What's the sequence of commands to replicate? Btw your output suggests the pytest ini file is not found, this is probably why, but need to know more about your commands before I can diagnose.

TheChymera commented 5 years ago

Trying to reproduce this manually, the sequence of commands is as follows:

chymera@localhost ~/src $ git clone git@github.com:schollii/pypubsub.git && cd pypubsub
Cloning into 'pypubsub'...
cd remote: Enumerating objects: 199, done.
remote: Counting objects: 100% (199/199), done.
remote: Compressing objects: 100% (155/155), done.
remote: Total 981 (delta 88), reused 86 (delta 41), pack-reused 782
Receiving objects: 100% (981/981), 508.36 KiB | 1.43 MiB/s, done.
Resolving deltas: 100% (510/510), done.
chymera@localhost ~/src/pypubsub $ git checkout aad1ced
chymera@localhost ~/src/pypubsub $ pytest -vv
============================================= test session starts ==============================================
platform linux -- Python 3.6.6, pytest-4.2.0, py-1.5.4, pluggy-0.8.1 -- /usr/bin/python3.6
cachedir: .pytest_cache
rootdir: /home/chymera/src/pypubsub, inifile:
collected 0 items                                                                                              

========================================= no tests ran in 0.03 seconds =========================================
chymera@localhost ~/src/pypubsub $ tree 
.
├── docs
│   ├── about.rst
│   ├── changelog.rst
│   ├── conf.py
│   ├── development
│   │   ├── dev_index.rst
│   │   ├── py2exe.rst
│   │   ├── setup-cxfreeze.py
│   │   ├── setup-py2exe.py
│   │   ├── sphinx_patch1.txt
│   │   ├── sphinx_patch2.txt
│   │   └── testpubsub.py
│   ├── index_redirect.php
│   ├── index.rst
│   ├── installation.rst
│   ├── make.bat
│   ├── Makefile
│   ├── pubsub_concept.png
│   └── usage
│       ├── core_classes.rst
│       ├── helloworld.py
│       ├── howtos
│       │   ├── arg1_to_kwargs.rst
│       │   ├── index.rst
│       │   └── upgrade_v1tov3.rst
│       ├── index.rst
│       ├── module_pub.rst
│       ├── module_utils.rst
│       ├── reference.rst
│       ├── setup_modules.rst
│       ├── types_of_errors.rst
│       ├── usage_advanced_debug.rst
│       ├── usage_advanced_maintain.rst
│       ├── usage_advanced_other.rst
│       ├── usage_advanced.rst
│       ├── usage_basic.rst
│       └── usage_basic_tasks.rst
├── examples
│   ├── advanced
│   │   ├── exchandle.py
│   │   ├── kwargs_listeners.py
│   │   ├── kwargs_senders.py
│   │   ├── kwargs_topics_out.py
│   │   ├── kwargs_topics.py
│   │   ├── main_kwargs.py
│   │   ├── notifhandle.py
│   │   └── README.txt
│   ├── basic_kwargs
│   │   ├── console_listeners.py
│   │   ├── console_main.py
│   │   ├── console_senders.py
│   │   ├── README.txt
│   │   ├── wx_main.py
│   │   ├── wx_win1.py
│   │   └── wx_win2.py
│   ├── multithreadloop.py
│   ├── runall.bat
│   └── runall_regression.txt
├── MANIFEST.in
├── README.txt
├── README_WxPython.txt
├── release.bat
├── setup.py
├── src
│   ├── contrib
│   │   ├── netpubsub.py
│   │   └── wx_monitor.py
│   ├── __init__.py
│   └── pubsub
│       ├── core
│       │   ├── callables.py
│       │   ├── __init__.py
│       │   ├── listener.py
│       │   ├── notificationmgr.py
│       │   ├── publisher.py
│       │   ├── topicargspec.py
│       │   ├── topicdefnprovider.py
│       │   ├── topicexc.py
│       │   ├── topicmgr.py
│       │   ├── topicobj.py
│       │   ├── topictreetraverser.py
│       │   ├── topicutils.py
│       │   └── weakmethod.py
│       ├── __init__.py
│       ├── LICENSE_BSD_Simple.txt
│       ├── policies.py
│       ├── pub.py
│       ├── readme.txt
│       ├── RELEASE_NOTES.txt
│       ├── setupkwargs.py
│       └── utils
│           ├── exchandling.py
│           ├── __init__.py
│           ├── misc.py
│           ├── notification.py
│           ├── topictreeprinter.py
│           └── xmltopicdefnprovider.py
├── tests
│   ├── perf.py
│   ├── pytest.ini
│   ├── readme.txt
│   ├── runperf.bat
│   └── suite
│       ├── my_import_topics.py
│       ├── raisinglistener.py
│       ├── test1_listener.py
│       ├── test2a_topic.py
│       ├── test2b_topicmgr.py
│       ├── test2c_notify2.py
│       ├── test2c_notify.py
│       ├── test2d_except.py
│       ├── test2_spec.py
│       ├── test3b_sel_default.py
│       ├── test3c_pubsub3.py
│       ├── test3d_defaultlog.py
│       ├── test4_provider.py
│       ├── test4_prov_module_expect.py
│       ├── test5_xmlprovider.py
│       └── xmlprovider_topics.xml
├── tools
│   └── compare_timings.py
├── tox-cov.ini
└── tox.ini

15 directories, 108 files

It seems there are just no tests detectable by pytest. Could that be correct?

schollii commented 5 years ago

have you tried, in the above manual run, to cd tests first? Also I notice the python version is 3.6, I think you wanted 2.7

TheChymera commented 5 years ago

@schollii ok, that was it :) The tests get run now, but I do get failures:

============================================= test session starts ==============================================
platform linux2 -- Python 2.7.15, pytest-4.2.0, py-1.5.4, pluggy-0.8.1 -- /usr/bin/python2.7
cachedir: .pytest_cache
rootdir: /var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests, inifile: pytest.ini
collecting ... collected 62 items

suite/test1_listener.py::test0_ArgsInfo PASSED                                                           [  1%]
suite/test1_listener.py::test2_Validation0 PASSED                                                        [  3%]
suite/test1_listener.py::test2_Validation1 PASSED                                                        [  4%]
suite/test1_listener.py::test3_IsCallable PASSED                                                         [  6%]
suite/test1_listener.py::test4_WantTopic PASSED                                                          [  8%]
suite/test1_listener.py::test5a_weakref PASSED                                                           [  9%]
suite/test1_listener.py::test5_DOAListeners_1 PASSED                                                     [ 11%]
suite/test1_listener.py::test5_DOAListeners_2 PASSED                                                     [ 12%]
suite/test1_listener.py::test6_ListenerEq PASSED                                                         [ 14%]
suite/test1_listener.py::test7_DyingListenersClass PASSED                                                [ 16%]
suite/test1_listener.py::test8_getArgsBadListener PASSED                                                 [ 17%]
suite/test1_listener.py::test10_weakMethod PASSED                                                        [ 19%]
suite/test1_listener.py::test11_testNaming PASSED                                                        [ 20%]
suite/test1_listener.py::test15_call PASSED                                                              [ 22%]
suite/test2_spec.py::test1_create PASSED                                                                 [ 24%]
suite/test2_spec.py::test2_update PASSED                                                                 [ 25%]
suite/test2_spec.py::test3_filter PASSED                                                                 [ 27%]
suite/test2a_topic.py::test0_CreateRoot PASSED                                                           [ 29%]
suite/test2a_topic.py::test1_SubUnsub PASSED                                                             [ 30%]
suite/test2a_topic.py::test2_CreateChild PASSED                                                          [ 32%]
suite/test2b_topicmgr.py::TestTopicMgr0_Basic::test10_GoodTopicNames PASSED                              [ 33%]
suite/test2b_topicmgr.py::TestTopicMgr0_Basic::test10_BadTopicNames PASSED                               [ 35%]
suite/test2b_topicmgr.py::TestTopicMgr1_GetOrCreate_NoDefnProv::test10_NoProtoListener PASSED            [ 37%]
suite/test2b_topicmgr.py::TestTopicMgr1_GetOrCreate_NoDefnProv::test20_WithProtoListener PASSED          [ 38%]
suite/test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test10_DefnProvider PASSED                 [ 40%]
suite/test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test20_UseProvider PASSED                  [ 41%]
suite/test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test30_DelTopic PASSED                     [ 43%]
suite/test2b_topicmgr.py::TestTopicMgr3_TreeTraverser::test1 PASSED                                      [ 45%]
suite/test2b_topicmgr.py::TestTopicMgr3_TreeTraverser::test2 PASSED                                      [ 46%]
suite/test2c_notify.py::testNotifyByPrint PASSED                                                         [ 48%]
suite/test2c_notify.py::testFlagChanges PASSED                                                           [ 50%]
suite/test2c_notify.py::testNotifications PASSED                                                         [ 51%]
suite/test2c_notify2.py::test0_NotificationTopics PASSED                                                 [ 53%]
suite/test2c_notify2.py::test1_SubscribeNotify PASSED                                                    [ 54%]
suite/test2c_notify2.py::test2_SendNotify PASSED                                                         [ 56%]
suite/test2d_except.py::testHandleExcept1a PASSED                                                        [ 58%]
suite/test2d_except.py::testHandleExcept1b PASSED                                                        [ 59%]
suite/test2d_except.py::testHandleExcept2 PASSED                                                         [ 61%]
suite/test2d_except.py::testNoExceptionHandling1 PASSED                                                  [ 62%]
suite/test2d_except.py::testNoExceptionHandling2 PASSED                                                  [ 64%]
suite/test3b_sel_default.py::test_import PASSED                                                          [ 66%]
suite/test3c_pubsub3.py::testDOAListenerPubsub PASSED                                                    [ 67%]
suite/test3c_pubsub3.py::testDeadListener PASSED                                                         [ 69%]
suite/test3c_pubsub3.py::testSubscribe PASSED                                                            [ 70%]
suite/test3c_pubsub3.py::testMissingReqdArgs PASSED                                                      [ 72%]
suite/test3c_pubsub3.py::testSendTopicWithMessage PASSED                                                 [ 74%]
suite/test3c_pubsub3.py::testAcceptAllArgs PASSED                                                        [ 75%]
suite/test3c_pubsub3.py::testSubscribeCurriedListeners PASSED                                            [ 77%]
suite/test3c_pubsub3.py::testSendWhenCurriedArgs PASSED                                                  [ 79%]
suite/test3c_pubsub3.py::testUnsubAll PASSED                                                             [ 80%]
suite/test3c_pubsub3.py::testSendForUndefinedTopic PASSED                                                [ 82%]
suite/test3c_pubsub3.py::testTopicUnspecifiedError PASSED                                                [ 83%]
suite/test3c_pubsub3.py::testArgSpecDerivation PASSED                                                    [ 85%]
suite/test3c_pubsub3.py::testListenerChangesListenerList PASSED                                          [ 87%]
suite/test3d_defaultlog.py::testNotifications PASSED                                                     [ 88%]
suite/test4_provider.py::test1 FAILED                                                                    [ 90%]
suite/test4_provider.py::test2_import_export_no_change FAILED                                            [ 91%]
suite/test4_provider.py::test_module_as_class PASSED                                                     [ 93%]
suite/test5_xmlprovider.py::test0_xml_from_file FAILED                                                   [ 95%]
suite/test5_xmlprovider.py::test1_xml_import FAILED                                                      [ 96%]
suite/test5_xmlprovider.py::test2_xml_string_import PASSED                                               [ 98%]
suite/test5_xmlprovider.py::test3_xml_topics PASSED                                                      [100%]

=================================================== FAILURES ===================================================
____________________________________________________ test1 _____________________________________________________

    def test1():
        class my_topics:
            class rootTopic1:
                """Root topic 1"""

                class subtopic_1:
                    """
                    Sub topic 1 of root topic. Docs rely on one blank line for
                    topic doc, and indentation for each argument doc.
                    """

                    def msgDataSpec(arg1, arg2=None):
                        """
                        - arg1: some multiline doc
                            for arg1
                        - arg2: some multiline doc
                            for arg2
                        """
                        pass

                    class subsubtopic_12:
                        """Sub sub topic 2 of sub topic 1."""

                        def msgDataSpec(arg1, argA, arg2=None, argB=None):
                            """
                            - argA: doc for argA
                            - argB: doc for argB
                            """
                            pass

            class rootTopic2:
                """Root topic 2"""

        pub.addTopicDefnProvider(my_topics, pub.TOPIC_TREE_FROM_CLASS)

        provString = '''
            class rootTopic1:
                class subtopic_1:
                    class subsubtopic_11:
                        """
                        Sub sub topic 1 of sub topic 1. Only need to doc the
                        extra args.
                        """
                        def msgDataSpec(arg1, arg3, arg2=None, arg4=None):
                            """
                            - arg3: doc for arg3
                            - arg4: doc for arg4
                            """
                            pass

                '''

>       pub.addTopicDefnProvider(provString, pub.TOPIC_TREE_FROM_STRING)

suite/test4_provider.py:68: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicmgr.py:125: in addDefnProvider
    provider = TopicDefnProvider(source, format or TOPIC_TREE_FROM_MODULE)
../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:385: in __init__
    provider.doneIter()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.core.topicdefnprovider.TopicDefnDeserialString instance at 0x7f62364d3248>

    def doneIter(self):
        self.__modDeserial.doneIter()
        # remove the temporary module and its compiled version (*.pyc)
        os.remove(self.__filename)
        try:  # py3.2+ uses special folder/filename for .pyc files
            from imp import cache_from_source
            os.remove(cache_from_source(self.__filename))
        except ImportError:
>           os.remove(self.__filename + 'c')
E           OSError: [Errno 2] No such file or directory: '/var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests/tmp_export_topics_V4FULG.pyc'

../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:335: OSError
________________________________________ test2_import_export_no_change _________________________________________

    def test2_import_export_no_change():
        #
        # Test that import/export/import does not change the import
        #

        importStr = '''
            """Tree docs, can be anything you want."""

            class test_import_export_no_change:
                """Root topic 1."""

                class subtopic_1:
                    """
                    Sub topic 1 of root topic. Docs rely on one
                    blank line for topic doc, and indentation for
                    each argument doc.
                    """

                    def msgDataSpec(arg1, arg2=None):
                        """
                        - arg1: some multiline doc
                            for arg1
                        - arg2: some multiline doc
                            for arg2
                        """
                        pass
            '''
        pub.clearTopicDefnProviders()
>       provider = pub.addTopicDefnProvider(importStr, pub.TOPIC_TREE_FROM_STRING)

suite/test4_provider.py:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicmgr.py:125: in addDefnProvider
    provider = TopicDefnProvider(source, format or TOPIC_TREE_FROM_MODULE)
../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:385: in __init__
    provider.doneIter()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.core.topicdefnprovider.TopicDefnDeserialString instance at 0x7f62364f0050>

    def doneIter(self):
        self.__modDeserial.doneIter()
        # remove the temporary module and its compiled version (*.pyc)
        os.remove(self.__filename)
        try:  # py3.2+ uses special folder/filename for .pyc files
            from imp import cache_from_source
            os.remove(cache_from_source(self.__filename))
        except ImportError:
>           os.remove(self.__filename + 'c')
E           OSError: [Errno 2] No such file or directory: '/var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests/tmp_export_topics_TxAp2K.pyc'

../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:335: OSError
_____________________________________________ test0_xml_from_file ______________________________________________

    def test0_xml_from_file():
        pub.clearTopicDefnProviders()

>       provider = XmlTopicDefnProvider('xmlprovider_topics.xml', TOPIC_TREE_FROM_FILE)

suite/test5_xmlprovider.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.utils.xmltopicdefnprovider.XmlTopicDefnProvider instance at 0x7f62366480e0>
xml = 'xmlprovider_topics.xml', format = 'file'

    def __init__(self, xml, format=TOPIC_TREE_FROM_STRING):
        self._topics = {}
        self._treeDoc = ''
        if format == TOPIC_TREE_FROM_FILE:
>           self._parse_tree(_get_elem(open(xml,mode="r").read()))
E           IOError: [Errno 2] No such file or directory: 'xmlprovider_topics.xml'

../../pypubsub-3.4.0-python2_7/lib/pubsub/utils/xmltopicdefnprovider.py:101: IOError
_______________________________________________ test1_xml_import _______________________________________________

    def test1_xml_import():
        pub.clearTopicDefnProviders()
        topicMgr.delTopic('parent')
        # verify pre:
        assert topicMgr.getTopic('parent', True) is None
        assert topicMgr.getTopic('parent.child', True) is None

>       provider = XmlTopicDefnProvider('xmlprovider_topics.xml', TOPIC_TREE_FROM_FILE)

suite/test5_xmlprovider.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.utils.xmltopicdefnprovider.XmlTopicDefnProvider instance at 0x7f6236650dd0>
xml = 'xmlprovider_topics.xml', format = 'file'

    def __init__(self, xml, format=TOPIC_TREE_FROM_STRING):
        self._topics = {}
        self._treeDoc = ''
        if format == TOPIC_TREE_FROM_FILE:
>           self._parse_tree(_get_elem(open(xml,mode="r").read()))
E           IOError: [Errno 2] No such file or directory: 'xmlprovider_topics.xml'

../../pypubsub-3.4.0-python2_7/lib/pubsub/utils/xmltopicdefnprovider.py:101: IOError
schollii commented 5 years ago

Try running it from "suite" folder

TheChymera commented 5 years ago

Ok, getting closer :)

============================================= test session starts ==============================================
platform linux2 -- Python 2.7.15, pytest-4.2.0, py-1.5.4, pluggy-0.8.1 -- /usr/bin/python2.7
cachedir: .pytest_cache
rootdir: /var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests, inifile: pytest.ini
collecting ... collected 62 items

test1_listener.py::test0_ArgsInfo PASSED                                                                 [  1%]
test1_listener.py::test2_Validation0 PASSED                                                              [  3%]
test1_listener.py::test2_Validation1 PASSED                                                              [  4%]
test1_listener.py::test3_IsCallable PASSED                                                               [  6%]
test1_listener.py::test4_WantTopic PASSED                                                                [  8%]
test1_listener.py::test5a_weakref PASSED                                                                 [  9%]
test1_listener.py::test5_DOAListeners_1 PASSED                                                           [ 11%]
test1_listener.py::test5_DOAListeners_2 PASSED                                                           [ 12%]
test1_listener.py::test6_ListenerEq PASSED                                                               [ 14%]
test1_listener.py::test7_DyingListenersClass PASSED                                                      [ 16%]
test1_listener.py::test8_getArgsBadListener PASSED                                                       [ 17%]
test1_listener.py::test10_weakMethod PASSED                                                              [ 19%]
test1_listener.py::test11_testNaming PASSED                                                              [ 20%]
test1_listener.py::test15_call PASSED                                                                    [ 22%]
test2_spec.py::test1_create PASSED                                                                       [ 24%]
test2_spec.py::test2_update PASSED                                                                       [ 25%]
test2_spec.py::test3_filter PASSED                                                                       [ 27%]
test2a_topic.py::test0_CreateRoot PASSED                                                                 [ 29%]
test2a_topic.py::test1_SubUnsub PASSED                                                                   [ 30%]
test2a_topic.py::test2_CreateChild PASSED                                                                [ 32%]
test2b_topicmgr.py::TestTopicMgr0_Basic::test10_GoodTopicNames PASSED                                    [ 33%]
test2b_topicmgr.py::TestTopicMgr0_Basic::test10_BadTopicNames PASSED                                     [ 35%]
test2b_topicmgr.py::TestTopicMgr1_GetOrCreate_NoDefnProv::test10_NoProtoListener PASSED                  [ 37%]
test2b_topicmgr.py::TestTopicMgr1_GetOrCreate_NoDefnProv::test20_WithProtoListener PASSED                [ 38%]
test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test10_DefnProvider PASSED                       [ 40%]
test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test20_UseProvider PASSED                        [ 41%]
test2b_topicmgr.py::TestTopicMgr2_GetOrCreate_DefnProv::test30_DelTopic PASSED                           [ 43%]
test2b_topicmgr.py::TestTopicMgr3_TreeTraverser::test1 PASSED                                            [ 45%]
test2b_topicmgr.py::TestTopicMgr3_TreeTraverser::test2 PASSED                                            [ 46%]
test2c_notify.py::testNotifyByPrint PASSED                                                               [ 48%]
test2c_notify.py::testFlagChanges PASSED                                                                 [ 50%]
test2c_notify.py::testNotifications PASSED                                                               [ 51%]
test2c_notify2.py::test0_NotificationTopics PASSED                                                       [ 53%]
test2c_notify2.py::test1_SubscribeNotify PASSED                                                          [ 54%]
test2c_notify2.py::test2_SendNotify PASSED                                                               [ 56%]
test2d_except.py::testHandleExcept1a PASSED                                                              [ 58%]
test2d_except.py::testHandleExcept1b PASSED                                                              [ 59%]
test2d_except.py::testHandleExcept2 PASSED                                                               [ 61%]
test2d_except.py::testNoExceptionHandling1 PASSED                                                        [ 62%]
test2d_except.py::testNoExceptionHandling2 PASSED                                                        [ 64%]
test3b_sel_default.py::test_import PASSED                                                                [ 66%]
test3c_pubsub3.py::testDOAListenerPubsub PASSED                                                          [ 67%]
test3c_pubsub3.py::testDeadListener PASSED                                                               [ 69%]
test3c_pubsub3.py::testSubscribe PASSED                                                                  [ 70%]
test3c_pubsub3.py::testMissingReqdArgs PASSED                                                            [ 72%]
test3c_pubsub3.py::testSendTopicWithMessage PASSED                                                       [ 74%]
test3c_pubsub3.py::testAcceptAllArgs PASSED                                                              [ 75%]
test3c_pubsub3.py::testSubscribeCurriedListeners PASSED                                                  [ 77%]
test3c_pubsub3.py::testSendWhenCurriedArgs PASSED                                                        [ 79%]
test3c_pubsub3.py::testUnsubAll PASSED                                                                   [ 80%]
test3c_pubsub3.py::testSendForUndefinedTopic PASSED                                                      [ 82%]
test3c_pubsub3.py::testTopicUnspecifiedError PASSED                                                      [ 83%]
test3c_pubsub3.py::testArgSpecDerivation PASSED                                                          [ 85%]
test3c_pubsub3.py::testListenerChangesListenerList PASSED                                                [ 87%]
test3d_defaultlog.py::testNotifications PASSED                                                           [ 88%]
test4_provider.py::test1 FAILED                                                                          [ 90%]
test4_provider.py::test2_import_export_no_change FAILED                                                  [ 91%]
test4_provider.py::test_module_as_class PASSED                                                           [ 93%]
test5_xmlprovider.py::test0_xml_from_file PASSED                                                         [ 95%]
test5_xmlprovider.py::test1_xml_import PASSED                                                            [ 96%]
test5_xmlprovider.py::test2_xml_string_import PASSED                                                     [ 98%]
test5_xmlprovider.py::test3_xml_topics PASSED                                                            [100%]

=================================================== FAILURES ===================================================
____________________________________________________ test1 _____________________________________________________

    def test1():
        class my_topics:
            class rootTopic1:
                """Root topic 1"""

                class subtopic_1:
                    """
                    Sub topic 1 of root topic. Docs rely on one blank line for
                    topic doc, and indentation for each argument doc.
                    """

                    def msgDataSpec(arg1, arg2=None):
                        """
                        - arg1: some multiline doc
                            for arg1
                        - arg2: some multiline doc
                            for arg2
                        """
                        pass

                    class subsubtopic_12:
                        """Sub sub topic 2 of sub topic 1."""

                        def msgDataSpec(arg1, argA, arg2=None, argB=None):
                            """
                            - argA: doc for argA
                            - argB: doc for argB
                            """
                            pass

            class rootTopic2:
                """Root topic 2"""

        pub.addTopicDefnProvider(my_topics, pub.TOPIC_TREE_FROM_CLASS)

        provString = '''
            class rootTopic1:
                class subtopic_1:
                    class subsubtopic_11:
                        """
                        Sub sub topic 1 of sub topic 1. Only need to doc the
                        extra args.
                        """
                        def msgDataSpec(arg1, arg3, arg2=None, arg4=None):
                            """
                            - arg3: doc for arg3
                            - arg4: doc for arg4
                            """
                            pass

                '''

>       pub.addTopicDefnProvider(provString, pub.TOPIC_TREE_FROM_STRING)

test4_provider.py:68: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicmgr.py:125: in addDefnProvider
    provider = TopicDefnProvider(source, format or TOPIC_TREE_FROM_MODULE)
../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:385: in __init__
    provider.doneIter()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.core.topicdefnprovider.TopicDefnDeserialString instance at 0x7f037a1c1d40>

    def doneIter(self):
        self.__modDeserial.doneIter()
        # remove the temporary module and its compiled version (*.pyc)
        os.remove(self.__filename)
        try:  # py3.2+ uses special folder/filename for .pyc files
            from imp import cache_from_source
            os.remove(cache_from_source(self.__filename))
        except ImportError:
>           os.remove(self.__filename + 'c')
E           OSError: [Errno 2] No such file or directory: '/var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests/suite/tmp_export_topics_RWwqGJ.pyc'

../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:335: OSError
________________________________________ test2_import_export_no_change _________________________________________

    def test2_import_export_no_change():
        #
        # Test that import/export/import does not change the import
        #

        importStr = '''
            """Tree docs, can be anything you want."""

            class test_import_export_no_change:
                """Root topic 1."""

                class subtopic_1:
                    """
                    Sub topic 1 of root topic. Docs rely on one
                    blank line for topic doc, and indentation for
                    each argument doc.
                    """

                    def msgDataSpec(arg1, arg2=None):
                        """
                        - arg1: some multiline doc
                            for arg1
                        - arg2: some multiline doc
                            for arg2
                        """
                        pass
            '''
        pub.clearTopicDefnProviders()
>       provider = pub.addTopicDefnProvider(importStr, pub.TOPIC_TREE_FROM_STRING)

test4_provider.py:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicmgr.py:125: in addDefnProvider
    provider = TopicDefnProvider(source, format or TOPIC_TREE_FROM_MODULE)
../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:385: in __init__
    provider.doneIter()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pubsub.core.topicdefnprovider.TopicDefnDeserialString instance at 0x7f037a4659e0>

    def doneIter(self):
        self.__modDeserial.doneIter()
        # remove the temporary module and its compiled version (*.pyc)
        os.remove(self.__filename)
        try:  # py3.2+ uses special folder/filename for .pyc files
            from imp import cache_from_source
            os.remove(cache_from_source(self.__filename))
        except ImportError:
>           os.remove(self.__filename + 'c')
E           OSError: [Errno 2] No such file or directory: '/var/tmp/portage/dev-python/pypubsub-3.4.0/work/pypubsub-3.4.0/tests/suite/tmp_export_topics_MRX9zq.pyc'

../../../pypubsub-3.4.0-python2_7/lib/pubsub/core/topicdefnprovider.py:335: OSError

Could be some compilation error?

schollii commented 5 years ago

Both errors are caused by the same problem: once iteration through the topic tree is done, the TopicDefnDeserialString instance tries to cleanup the compiled python file (*.pyc) created by Python (because this deserializer uses Python to parse the files!). These live in different places in python 2.7 vs 3.x hence the first try which attempts python 3.2+ method, and if this fails it assumes must be python 2.x.

On ubuntu, I do NOT get that error (nor on Windows). The error you get indicates that the 2.x pyc are not where they normally are, ie. something is special about your platform or installation.

The easiest would probably be for you to share your desktop over a Slack or Hangouts chat.

TheChymera commented 5 years ago

You mean you would be willing to look into this on a Gentoo platform? In that case I would rather set up a virtual server and give you ssh. works for you?

schollii commented 5 years ago

Sure that works too. If you could be on gitter while I'm ssh'd in there, in case I have questions, it'll speed things up. Theres a pypubsub channel.

schollii commented 5 years ago

OK so I identified that on the gentoo server, the .pyc files are not generated. DId not investigate why, although this did point to a weakness in the code of doneIter(): it should check for both the .pyc and .pyo files, and it should not fail if it cannot find them. E.g. if PYTHONDONTWRITEBYTECODE is true then the .pyc/pyo files will not be created. Made this fix on the 3.4 branch, tests now pass.

I created #37 to finish the source changes required to release 3.4 (just docs AFAICT).