No project description provided
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tempground-0.4.3.tar.gz
.
File metadata
- Download URL: tempground-0.4.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 096a74c04bca752d08f0d0be4bf8861bed57f18ff39160c76b6abf8ea478916d |
|
MD5 | d9d6fbea678d629454db0a0c39539bc4 |
|
BLAKE2b-256 | ecdbd405cd4db1aac6279514c3624b31cff7a784813c9ba340079f51fb3ab0cb |
File details
Details for the file tempground-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: tempground-0.4.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 265e1f083f87046d72a854d5475baeee49cf810a8fa990f2dcfb404372ae4215 |
|
MD5 | 0c6e73dd29aecdb0de86e8e0a1ac7d1d |
|
BLAKE2b-256 | 27f784e870e58bf7640aa54dde2ab3ce218b9f3ce1e40c951a98d415768a9bcb |