Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 694991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:54:48+00:00 2026-05-14T02:54:48+00:00

I have problem concerning python packages and testing. I’m writing an application using wx

  • 0

I have problem concerning python packages and testing. I’m writing an application using wx python and have the following basic folder/package structure for the gui parts. The mainframe.py window has a dependency to the logpane.py panel, which is easily imported using an absolute import in mainframe.py:

import guiapp.utilviews.logpane

Folder/package layout:

mainapp
   - main.py
   guiapp
       - __init__.py
       utilviews
           - __init__.py
           - logpane.py
           - other stuff...
       mainview
           - __init__.py
           - mainframe.py
           - other stuff here...
       other views...

However, for the gui parts of the application I’d like to, in addition to unit tests (and they pose no problem), have a small “test”/example for each view. That is, for the logpane, I’d like to have small runnable example that will lauch a bare bone application showing the view to test that layout is ok etc.
The way I started out was that I had a

if __name__ == "__main__":
    # create some small window and a wx app
    # instanciate the panel and launch the app
    pass

in the actual implementation file of the panel/view itself. This worked wonders for the logpane. I could just run the file standalone to have a look at the view and see that it held together.

But of course the strategy broke down for the mainframe.py since the dependency to logpane.py couldn’t be resolved. This since the current main module is the mainframe.py and the only way mainframe.py can reach the utilviews package is if the main/launched module is further up in the tree.

So how do I structure these types of tests? For unit tests I use nose which is nice and takes care of the problem since nose is launched per the mainapp folder (so all intrapackage references works). But these tests are like small stand-alone programs. I simply can’t clutter the mainapp folder with these python files (there will be many such files). Are there any other way I can accomplish this?

Any input is valuable.

Thanks,
Rickard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:54:49+00:00Added an answer on May 14, 2026 at 2:54 am

    You could use PYTHONPATH. Set it to your main project directory, before executing your test file. It will then be able to resolve all your imports just as if you would be executing from that directory.

    $ find
    .
    ./test
    ./test/test.py
    ./some
    ./some/__init__.py
    
    $ cat some/__init__.py 
    x = 10
    
    $ cat test/test.py 
    import some
    print some.x
    
    $ cd test
    $ export PYTHONPATH=..
    $ python test.py
    10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using LaTeX and I have a problem concerning string manipulation. I want
I have a problem with Visual Studio 2008 concerning virtual inheritance. Consider the following
I have a problem concerning the reading of the stdout in python. I have
I have a problem concerning a HashMap in Java. To explain the problem in
I have a problem concerning the width of a DialogPreference in Android. According to
i have a problem concerning a select query in MYSQL i have two different
i am currently working on a facebook game and i have a problem concerning
I have quite a problem concerning the use of relational database concepts in Delphi
I'm a beginner concerning socket programming and I have a problem when I send
I have a problem converting a string binary to a decimal I was using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.