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 9216735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:28:49+00:00 2026-06-18T02:28:49+00:00

I’m developing my first Python distribution package. My learning curve on Python packaging seems

  • 0

I’m developing my first Python distribution package. My learning curve on
Python packaging seems to be leveling off a bit, but I’m still wrestling with
a few open questions. One is whether I should cause my unit tests to be
installed alongside my code.

I understand it’s important to include tests in a source distribution. What I’m wondering is whether I should actually configure them to be installed?

I’ve seen at least one popular package that appears to do this on purpose
(PyHamcrest), and at least one other that appears to do it by accident
(behave).

So my (multi-part) question is this:

  • Does it ever make sense to install my package unit tests alongside my
    package code?

  • If so, what is the use case? Who would use them and for what? That is, who
    would use them that wouldn’t be perfectly happy to download the source
    distribution and run python setup.py test instead?

  • And how would they use installed unit tests? like import test; test.run() or something
    like that?

  • 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-18T02:28:50+00:00Added an answer on June 18, 2026 at 2:28 am

    After researching this issue, and until someone more experienced has a minute to weigh in to the contrary, my understanding is that the simple answer is: “No, unit tests should not be installed, only included in the source distribution“.

    In the handful of cases I found where tests were installed, all turned out to be accidental and it’s easier than one might think to make the mistake without noticing it.

    Here’s how it happens:

    1. The packages=find_packages() parameter is used in setup.py so packages can be found without having to list them out explicitly.
    2. The test folder is made into a package (by adding __init__.py) so tests can reference the modules they test using relative naming (like from .. import pkg.mod).
    3. setuptools installs test as a separate package, alongside the other(s) in the project. Note this means you can execute import test in the python interpreter and it works, almost certainly not what you intended, especially since a lot of other folks use that name for their test directory 🙂

    The fix is to use the setting: packages=find_packages(exclude=['test']) to prevent your test directory from being installed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
I need to clean up various Word 'smart' characters in user input, including but
I'm making a simple page using Google Maps API 3. My first. One marker

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.