File: test-helper.py

package info (click to toggle)
todo.txt-base 2.7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: python: 476; makefile: 17; sh: 16
file content (48 lines) | stat: -rwxr-xr-x 1,014 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python3

import os
import sys
from pathlib import Path
from subprocess import run

WORKDIR = "/tmp"
work_path = Path(WORKDIR)

# TODO - temp
if Path("/usr/bin/topydo-helper").exists():
    sys.exit(0)

if "AUTOPKGTEST_ARTIFACTS" in os.environ:
    artifact_path = Path(os.environ["AUTOPKGTEST_ARTIFACTS"])
else:
    artifact_path = work_path

config_path = work_path / "topydo.conf"

start_path = Path(os.getcwd())
os.chdir(WORKDIR)

if config_path.exists():
    config_path.unlink()

with open(str(config_path), "w") as fp:
    fp.write("[topydo]\n")
    fp.write("filename = /tmp/todo.txt\n")

cp = run(["topydo", "--info"], capture_output=True, encoding="utf-8")
passed = False
for line in cp.stdout.split("\n"):
    if line == "task_path = /tmp/todo.txt":
        passed = True

with open(str(artifact_path / "todo.txt-helper-config.txt"), "w") as fp:
    fp.write(cp.stdout)

config_path.unlink()

os.chdir(str(start_path))

if not passed:
    print("Did not find task file path")

    sys.exit(1)