Skip to main content

Generic badge Generic badge

tempground

A script that allows you to concisely:

  • create a temp directory
  • fill the directory with files of known content
  • run shell commands in the directory
  • check the run results

For example, during integration testing of a library, we can create a small temporary project that imports our library. And we check that the library was imported.

Example: Testing a Kotlin library

Suppose you have created a Kotlin library named mylib. You need to test that third-party projects can use mylib as a dependency.

The test can be run by creating a single file like this:

# lib_test.py

from tempground import *

with TempGround(
        files={
            # minimalistic build script to use the library
            "build.gradle.kts": """
                plugins {
                    id("application")
                    kotlin("jvm") version "1.6.10"
                }
                
                repositories { mavenCentral() }
                application { mainClass.set("MainKt") }
                
                dependencies {
                    implementation("io.github.username:mylib")
                }            
            """,

            # additional settings, if necessary 
            "settings.gradle.kts": """
                sourceControl {
                    gitRepository(java.net.URI("https://github.com/username/mylib.git")) {
                        producesModule("io.github.username:mylib")
                    }
                }            
            """,

            # kotlin code that imports and uses the library
            "src/main/kotlin/Main.kt": """
                import io.github.username:mylib.spanishGreeting
                fun main() = println(spanishGreeting())
            """}) as app:
    
    # print report about our mini-project
    print(app.files_content())
    
    # run our mini-project
    result = app.run(["gradle", "run", "-q"])
    
    # print what was on stdout, the exit code, etc 
    print(result)
    
    # check everything was as excepted
    assert result.returncode == 0
    assert result.stdout == "¡Hola!\n"

print("Everything is OK!")

To run the test on a clean system, install tempground and run the script:

# assuming pip and python are Python 3.10+
# and lib_test.py is a local file

$ pip install tempground
$ python lib_test.py

License

Copyright © 2022 Artsiom iG. Released under the MIT License.

Metadata

Release files for tempground 0.4.3

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

Source distribution (sdist)

Source distribution for tempground 0.4.3
File Size Uploaded Provenance Actions
tempground-0.4.3.tar.gz 5.7 kB Without provenance Details for tempground-0.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tempground 0.4.3
File Interpreter ABI Platform Actions
tempground-0.4.3-py3-none-any.whl Python 3 none any Details for tempground-0.4.3-py3-none-any.whl

Total release size: 12.6 kB

Release files / tempground-0.4.3.tar.gz

Download URL tempground-0.4.3.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
096a74c04bca752d08f0d0be4bf8861bed57f18ff39160c76b6abf8ea478916d
BLAKE2b-256 checksum
How to use checksums
ecdbd405cd4db1aac6279514c3624b31cff7a784813c9ba340079f51fb3ab0cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / tempground-0.4.3-py3-none-any.whl

Download URL tempground-0.4.3-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
265e1f083f87046d72a854d5475baeee49cf810a8fa990f2dcfb404372ae4215
BLAKE2b-256 checksum
How to use checksums
27f784e870e58bf7640aa54dde2ab3ce218b9f3ce1e40c951a98d415768a9bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Security for tempground 0.4.3

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.

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