Skip to content

Commit 2e4053f

Browse files
committed
Add tests for StringCommand bit that aren't strings.
1 parent 5000182 commit 2e4053f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/test_api/test_api_command.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
from unittest import TestCase
44

5+
try:
6+
from pathlib import Path
7+
HAS_PATHLIB = True
8+
except ImportError:
9+
HAS_PATHLIB = False
10+
11+
import pytest
12+
513
from pyinfra.api import (
614
FileDownloadCommand,
715
FileUploadCommand,
@@ -52,9 +60,25 @@ def test_eq(self):
5260
assert StringCommand('a') == StringCommand('b')
5361

5462
def test_separator(self):
55-
cmd = StringCommand('hello world', 'yes', separator='')
63+
cmd = StringCommand('hello world', 'yes', _separator='')
5664
assert str(cmd) == 'hello worldyes'
5765

66+
def test_int(self):
67+
cmd = StringCommand('hello', 'world', 4420)
68+
assert str(cmd) == 'hello world 4420'
69+
70+
def test_list(self):
71+
cmd = StringCommand('hello', 'world', ['a', 'b', 'c'])
72+
assert str(cmd) == "hello world ['a', 'b', 'c']"
73+
74+
@pytest.mark.skipif(
75+
not HAS_PATHLIB,
76+
reason='Requires Python 3.4+ (pathlib module)',
77+
)
78+
def test_path(self):
79+
cmd = StringCommand('hello', 'world', Path('/path/to/somewhere'))
80+
assert str(cmd) == 'hello world /path/to/somewhere'
81+
5882

5983
class TestFileCommands(TestCase):
6084
def test_file_upload_command_repr(self):

0 commit comments

Comments
 (0)