Skip to content

test vs. tests #1165

Closed as not planned
Closed as not planned

Description

@DimitriPapadopoulos

Should tests live in directory test or tests? The guide seems inconsistent to me, but I'm new to contemporary Python packaging, so I may have missed something.

It is test in guides/using-manifest-in.rst:

How files are included in an sdist

The following files are included in a source distribution by default:

  • ...
  • all files matching the pattern test/test*.py

and tests in tutorials/packaging-projects.rst:

Creating a test directory

tests/ is a placeholder for test files. Leave it empty for now.

Is tests always the expected name for the directory containing tests? Could/should the guide standardize on that?

Activity

  1. webknjaz commented on Nov 19, 2022

    @webknjaz
    Member

    I think you're right, using the plural tests/ is more common. The name is not restricted programmatically, but it is nicer to have a unified convention. So far, I've only seen one project using a singular test/ folder, but they are moving toward tests/ where possible, too.

  2. added
    type: enhancement
    type: task
    on Nov 19, 2022
  3. DimitriPapadopoulos commented on Nov 20, 2022

    @DimitriPapadopoulos
    ContributorAuthor

    The name has to be matched/restricted at some point:

    The following files are included in a source distribution by default:

    • ...
    • all files matching the pattern test/test*.py

    I cannot find the relevant code in the pypa repositories, as I don't know which package would do the matching.

    The pypa repositories seem to be commonly using test/.

  4. DimitriPapadopoulos commented on Nov 20, 2022

    @DimitriPapadopoulos
    ContributorAuthor

    I think I have found the relevant source code in setuptools:

    setuptools/_distutils/command/sdist.py
    Lines 295 to 296 in 59ee498

        def _add_defaults_optional(self):
            optional = ['test/test*.py', 'setup.cfg']

    copied over from distutils:

    distutils/command/sdist.py
    Lines 295 to 296 in e0787fa

        def _add_defaults_optional(self):
            optional = ['test/test*.py', 'setup.cfg']
  5. DimitriPapadopoulos commented on Nov 20, 2022

    @DimitriPapadopoulos
    ContributorAuthor

    I have created pypa/distutils#187 to investigate directly in distutils.

  6. merwok commented on Aug 6, 2026

    @merwok
    Member

    Not sure the guide should be changed here.

    This convention can be discovered by people looking at existing projects. Build backend config is another thing entirely (setuptools defaults, include all files, explicit list…), we don’t want to duplicate their doc.

  7. rgommers commented on Nov 11, 2026

    @rgommers
    Contributor

    I agree with @merwok, I suggest we close this issue.

  8. merwok commented on Nov 11, 2026

    @merwok
    Member

    The inconsistency is gone as the guide about manifest.in is removed.

    Note that setuptools was changed to also include tests/test*.py by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: guidescomponent: tutorialstype: enhancementtype: task

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions