use tempfile
This commit is contained in:
parent
1ce5b1f87a
commit
c55af97f3b
@ -5,10 +5,12 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from scripttest import TestFileEnvironment
|
from scripttest import TestFileEnvironment as TFE
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
import escpos
|
import escpos
|
||||||
|
|
||||||
TEST_DIR = os.path.abspath("test/test-cli-output")
|
TEST_DIR = tempfile.mkdtemp() + "/cli-test"
|
||||||
|
|
||||||
DEVFILE_NAME = "testfile"
|
DEVFILE_NAME = "testfile"
|
||||||
|
|
||||||
@ -36,13 +38,14 @@ class TestCLI:
|
|||||||
def teardown_class(cls):
|
def teardown_class(cls):
|
||||||
"""Remove config file"""
|
"""Remove config file"""
|
||||||
os.remove(CONFIGFILE)
|
os.remove(CONFIGFILE)
|
||||||
|
shutil.rmtree(TEST_DIR)
|
||||||
|
|
||||||
def setup_method(self):
|
def setup_method(self):
|
||||||
"""Create a file to print to and set up env"""
|
"""Create a file to print to and set up env"""
|
||||||
self.env = None
|
self.env = None
|
||||||
self.default_args = None
|
self.default_args = None
|
||||||
|
|
||||||
self.env = TestFileEnvironment(
|
self.env = TFE(
|
||||||
base_path=TEST_DIR,
|
base_path=TEST_DIR,
|
||||||
cwd=os.getcwd(),
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
@ -96,7 +99,7 @@ class TestCLI:
|
|||||||
assert DEVFILE_NAME in result.files_updated.keys()
|
assert DEVFILE_NAME in result.files_updated.keys()
|
||||||
assert result.files_updated[DEVFILE_NAME].bytes == test_text + "\n"
|
assert result.files_updated[DEVFILE_NAME].bytes == test_text + "\n"
|
||||||
|
|
||||||
def test_cli_text_inavlid_args(self):
|
def test_cli_text_invalid_args(self):
|
||||||
"""Test a failure to send valid arguments"""
|
"""Test a failure to send valid arguments"""
|
||||||
result = self.env.run(
|
result = self.env.run(
|
||||||
*(self.default_args + ("text", "--invalid-param", "some data")),
|
*(self.default_args + ("text", "--invalid-param", "some data")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user