|
| 1 | +import os |
| 2 | + |
1 | 3 | from pathlib import Path |
2 | 4 | from platform import system |
| 5 | +from tempfile import mkstemp |
| 6 | +from textwrap import dedent |
3 | 7 |
|
4 | 8 | from invoke import run, task |
5 | 9 |
|
@@ -48,18 +52,35 @@ def coverage(context): |
48 | 52 | pty=(not system() == 'Windows')) |
49 | 53 | run('coverage html') |
50 | 54 |
|
| 55 | +def _setup_atest(): |
| 56 | + _, tempconf = mkstemp() |
| 57 | + with open(tempconf, 'w') as f: |
| 58 | + f.write('''dummy_handler_metadata: |
| 59 | + handler: MyDummyMetadataHandler |
| 60 | + keyword: run_metadata_dummy_handler |
| 61 | + tags: oxygen-metadata''') |
| 62 | + return (tempconf, |
| 63 | + os.pathsep.join([str(SRCPATH), |
| 64 | + str(UNIT_TESTS / 'resources' / 'my_dummy_handlers')])) |
| 65 | + |
51 | 66 | @task(help={ |
52 | 67 | 'rf': 'Additional command-line arguments for Robot Framework as ' |
53 | 68 | 'single string. E.g: invoke atest --rf "--name my_suite"' |
54 | 69 | }) |
55 | 70 | def atest(context, rf=''): |
56 | | - run(f'robot ' |
57 | | - f'--pythonpath {str(SRCPATH)} ' |
58 | | - f'--dotted ' |
59 | | - f'{rf} ' |
60 | | - f'--listener oxygen.listener ' |
61 | | - f'{str(CURDIR / "tests" / "atest")}', |
62 | | - pty=(not system() == 'Windows')) |
| 71 | + tempconf, pythonpath = _setup_atest() |
| 72 | + run(f'python -m oxygen --add-config {tempconf}', |
| 73 | + env={'PYTHONPATH': pythonpath}) |
| 74 | + try: |
| 75 | + run(f'robot ' |
| 76 | + f'--pythonpath {pythonpath} ' |
| 77 | + f'--dotted ' |
| 78 | + f'{rf} ' |
| 79 | + f'--listener oxygen.listener ' |
| 80 | + f'{str(CURDIR / "tests" / "atest")}', |
| 81 | + pty=(not system() == 'Windows')) |
| 82 | + finally: |
| 83 | + run('python -m oxygen --reset-config', env={'PYTHONPATH': pythonpath}) |
63 | 84 |
|
64 | 85 | @task |
65 | 86 | def test(context): |
|
0 commit comments