简体   繁体   中英

Refreshing a package project in Eclipse PyDev

I have a PyDev project that is organized like this (I have omitted the .git directory). The aim is to build a package called stattests .

    |   .gitignore
    |   .project
    |   .pydevproject
    |   
    +---.git
    +---stattests
    |   |   setup.py
    |   |   
    |   +---tests
    |   |   |   tests.py
    |   |   |   __init__.py
    |           
    \---unittests
            tests1.py

The top level directory stattests contains the setup.py file, and the sub-folder tests , a module that contains an __init__.py which imports all the functions from tests.py in the same module folder. Note that tests here are not unit tests, but statistical tests.

Unit tests are contained in the unittests folder, and the which looks like this:

# unittests/tests1.py
from stattests.tests import tests
series1 = pd.Series(np.random.randn(10))
tests.test1(series1)

When I execute this testing script it does not refresh the definition of the stattests.tests.test1 function, and uses an old definition instead.

I have also manually added all the folder and subfolders of the project to the project PYTHONPATH property.

Help appreciated.

Do you have: 'User Module Deleter (UMD)' (preferences > pydev > interactive console > user module deleter) > enable UMD activated?

Ie: If you are only sending it to the console modules are cached in sys.module, so, imported modules aren't usually re-evaluated... now, UMD, if enabled, tries to force those to reload by using 'runfile' instead of 'execfile) -- although this can be sometimes tricky, so, it may fail too -- so, if you want to do a simple run, the recommended way is running with F9 (run current module), and Ctrl+Alt+Enter is recommended if you want to use the symbols defined afterwards interactively in the shell.

If it isn't updating then you can clear the cache and make sure you edited and saved the right file. In the project structure there should be a folder called pycache just delete it. Another way to refresh in eclipse is to right click > refresh on the project in the PyDevPackage Explorer or press F5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM