Skip to main content

temp_dir

Change into newly created temporary directory for executing a block of code.

Upon leaving the code block the temporary directory and all its contents are removed and the original working directory is restored.

Intended as a tool to ease “integration” testing.

The package contains only two functions: in_temp_dir to be used with the with statement and within_temp_dir to decorate a function.

Examples

Function decorator:

@within_temp_dir
def f():
    return os.getcwd()


class TestScript(unittest.TestCase):

    @within_temp_dir
    def test_output_file_created(self):
        self.create_input_file()
        call_script('input')
        self.assertTrue(os.path.exists('output'))

Context manager:

with in_temp_dir():
    with open('tempfile', 'w') as f:
        f.write(...)
    process_file('tempfile')

Similar functionality elsewhere

Similar functionality can be found at

Metadata

Release files for temp_dir 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for temp_dir 0.1.1
File Size Uploaded Provenance Actions
temp_dir-0.1.1.tar.gz 2.7 kB Without provenance Details for temp_dir-0.1.1.tar.gz

Release files / temp_dir-0.1.1.tar.gz

Download URL temp_dir-0.1.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d11a43aef656bb00cdcd89e159803f88c5cc8a3aa4ca40c45bb7e5fd02c8bb5f
BLAKE2b-256 checksum
How to use checksums
ae111decdc521eb191f4ecef1d71c88366fae5fecf0506fd270ae099581ae299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for temp_dir 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page