{"id":23344381,"url":"https://github.com/rec/tdir","last_synced_at":"2026-03-04T18:31:42.497Z","repository":{"id":44669613,"uuid":"266781091","full_name":"rec/tdir","owner":"rec","description":"🗃 Create, fill a temporary directory 🗃","archived":false,"fork":false,"pushed_at":"2026-01-30T15:43:56.000Z","size":807,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-31T05:18:54.410Z","etag":null,"topics":["python","tempfile","temporary-directory","testing"],"latest_commit_sha":null,"homepage":"https://rec.github.io/tdir/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rec.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rec"}},"created_at":"2020-05-25T13:04:23.000Z","updated_at":"2026-01-30T15:44:01.000Z","dependencies_parsed_at":"2023-01-22T09:50:16.185Z","dependency_job_id":"ab1f87b1-b294-4f18-9e84-57ca0ae95ab6","html_url":"https://github.com/rec/tdir","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"9e96ac783c190115d5e0816ef9084b1bbc29b57f"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/rec/tdir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rec%2Ftdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rec%2Ftdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rec%2Ftdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rec%2Ftdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rec","download_url":"https://codeload.github.com/rec/tdir/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rec%2Ftdir/sbom","scorecard":{"id":767035,"data":{"date":"2025-08-11","repo":{"name":"github.com/rec/tdir","commit":"f79c474494f8b15c3f2c5cc26dce88a54fc21707"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:5: update your workflow using https://app.stepsecurity.io/secureworkflow/rec/tdir/python-package.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/rec/tdir/python-package.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/rec/tdir/python-package.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-package.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/rec/tdir/python-package.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/rec/tdir/python-package.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:08:20.977Z","repository_id":44669613,"created_at":"2025-08-23T01:08:20.977Z","updated_at":"2025-08-23T01:08:20.977Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30089331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T18:31:08.343Z","status":"ssl_error","status_checked_at":"2026-03-04T18:31:07.708Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","tempfile","temporary-directory","testing"],"created_at":"2024-12-21T06:26:29.116Z","updated_at":"2026-03-04T18:31:42.465Z","avatar_url":"https://github.com/rec.png","language":"Python","funding_links":["https://github.com/sponsors/rec"],"categories":[],"sub_categories":[],"readme":"# 🗃 tdir - create and fill a temporary directory 🗃\n\nRun code inside a temporary directory filled with zero or more files.\n\nVery convenient for writing tests: you can decorate individual tests or a whole\ntest suite.\n\n`tdir()` runs code in a temporary directory pre-filled with files: it can\neither be used as a context manager, or a decorator for functions or classes.\n\n`tdir.fill()` is a tiny function that recursively fills a directory.\n\n## Example: as a context manager\n\n    from pathlib import Path\n    import tdir\n\n    cwd = Path.cwd()\n\n    # Simplest invocation.\n\n    with tdir():\n       # Do a lot of things in a temporary directory\n\n    # Everything is gone!\n\n    # With a single file\n    with tdir('hello') as td:\n        # The file `hello` is there\n        assert Path('hello').read_text() = 'hello\\n'\n\n        # We're in a temporary directory\n        assert td == Path.cwd()\n        assert td != cwd\n\n        # Write some other file\n        Path('junk.txt').write_text('hello, world\\n')\n\n    # The temporary directory and the files are gone\n    assert not td.exists()\n    assert cwd == Path.cwd()\n\n    # A more complex example:\n    #\n    with tdir(\n        'one.txt',\n        three='some information',\n        four=Path('existing/file'),  # Copy a file into the tempdir\n        sub1={\n            'file.txt': 'blank lines\\n\\n\\n\\n',\n            'sub2': [\n                'a', 'b', 'c'\n            ]\n        },\n    ):\n        assert Path('one.txt').exists()\n        assert Path('four').read_text() == Path('/existing/file').read_text()\n        assert Path('sub1/sub2/a').exists()\n\n    # All files gone!\n\n## Example: as a decorator\n\n    from pathlib import Path\n    import tdir\n    import unittest\n\n    @tdir\n    def my_function():\n        pass  # my_function() always operates in a temporary directory\n\n\n    # Decorate a TestCase so each test runs in a new temporary directory\n    # with two files\n    @tdir('a', foo='bar')\n    class MyTest(unittest.TestCast):\n        def test_something(self):\n            assert Path('a').read_text() = 'a\\n'\n\n        def test_something_else(self):\n            assert Path('foo').read_text() = 'bar\\n'\n\n\n    class MyTest2(unittest.TestCast):\n        # Decorate just one test in a unitttest\n        @tdir(foo='bar', baz=bytes(range(4)))  # binary files are possible\n        def test_something(self):\n            assert Path('foo').read_text() = 'bar\\n'\n            assert Path('baz').read_bytes() = bytes(range(4)))\n\n        # Run test in an empty temporary directory\n        @tdir\n        def test_something_else(self):\n            assert not Path('a').exists()\n            assert Path().absolute() != self.ORIGINAL_PATH\n\n        ORIGINAL_PATH = Path().absolute()\n\n\n### [API Documentation](https://rec.github.io/tdir#tdir--api-documentation)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frec%2Ftdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frec%2Ftdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frec%2Ftdir/lists"}