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

  • SEARCH
  • Home
  • 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 9233645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:36:14+00:00 2026-06-18T06:36:14+00:00

My project hierarchy goes like this project src fruit_pkg count_fruits.py test fruit_pkg test_count_fruits.py Now

  • 0

My project hierarchy goes like this

project 
       src
          fruit_pkg
            count_fruits.py
       test
          fruit_pkg
             test_count_fruits.py

Now say inside the module count_fruits.py I have a function called addition. In order to test addition, do I have to import the count_fruits module using

my_mod = __import__("fruit_pkg.count_fruits")
cnt_fruit = getattr(my_mod,"count_fruits")

and then for my test do something like

def my_test(self):
  #some work happen here
  cnt_fruit.addition(blah, blah)
  #more work happen here

Or: since both the src and the test codes are in the same package fruit_pkg, is there a simpler way to access the functions inside count_fruits.

For parallel, in Java, if both the src and the junit test codes are inside the same package, no import is necessary at all.

  • 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-06-18T06:36:15+00:00Added an answer on June 18, 2026 at 6:36 am

    Unless fruit_pkg is a namespace package; it is available only from one directory. Look at sys.modules['fruit_pkg'] to find out which one.

    You could move tests to src/fruit_pkg/test/test_count_fruits.py or don’t use the same top-level name for testing packages.

    Either way, to import the module:

    from fruit_pkg import count_fruits
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project hierarchy like this, with a bazaar repository that has been
My Django project's directory hierarchy looks like this: + pybsd |---+ devices |---+ templates
I have a maven multi-module project having hierarchy: parent + ota-module + ota-common +
In my project, I have a problem with its dependency hierarchy. I use a
I have a C# project with many classes. Is it possible to pack this
I am new to Asp.Net Mvc. This is my solution hierarchy PROJECT --Area --
I have a maven project with the following hierarchy as created with NetBeans: root/
The project is an Asp.Net Web API web service. I have a type hierarchy
In my Scala project I have quite a broad & deep hierarchy of classes
My project hierarchy - MyProject -> myapp -> MyPackage -> models.py . In this

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.