File: helpers.py

package info (click to toggle)
python-docx 1.2.0%2Bdfsg-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 7,216 kB
  • sloc: xml: 25,323; python: 23,414; makefile: 175
file content (34 lines) | stat: -rw-r--r-- 836 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
"""Helper methods and variables for acceptance tests."""

import os


def absjoin(*paths: str) -> str:
    return os.path.abspath(os.path.join(*paths))


thisdir: str = os.path.split(__file__)[0]
scratch_dir: str = absjoin(thisdir, "../_scratch")

# scratch output docx file -------------
saved_docx_path: str = absjoin(scratch_dir, "test_out.docx")

bool_vals = {"True": True, "False": False}

test_text = "python-docx was here!"

tri_state_vals = {
    "True": True,
    "False": False,
    "None": None,
}


def test_docx(name: str):
    """Return the absolute path to test .docx file with root name `name`."""
    return absjoin(thisdir, "test_files", "%s.docx" % name)


def test_file(name: str):
    """Return the absolute path to file with `name` in test_files directory"""
    return absjoin(thisdir, "test_files", "%s" % name)