diff --git a/src/p4p/test/test_gw.py b/src/p4p/test/test_gw.py index 7dccd5fb..f740fc5a 100644 --- a/src/p4p/test/test_gw.py +++ b/src/p4p/test/test_gw.py @@ -43,8 +43,20 @@ def test_config(self): content = F.read() self.assertRegex(content, '"statusprefix"') - def test_systemd(self): - with NamedTemporaryFile() as F: + def test_systemd_instance(self): + with NamedTemporaryFile(suffix='@blah.service') as F: + try: + main(['--example-systemd', F.name]) + except SystemExit as e: + self.assertEqual(e.code, 0) + + F.seek(0) + content = F.read() + self.assertRegex(content, '-m p4p.gw /etc/pvagw/blah.conf') + self.assertRegex(content, 'multi-user.target') + + def test_systemd_template(self): + with NamedTemporaryFile(suffix='@.service') as F: try: main(['--example-systemd', F.name]) except SystemExit as e: @@ -52,6 +64,7 @@ def test_systemd(self): F.seek(0) content = F.read() + self.assertRegex(content, '-m p4p.gw /etc/pvagw/%i.conf') self.assertRegex(content, 'multi-user.target') class TestGC(RefTestCase): diff --git a/src/p4p/test/utils.py b/src/p4p/test/utils.py index 8f7b59ca..4b8d1507 100644 --- a/src/p4p/test/utils.py +++ b/src/p4p/test/utils.py @@ -170,7 +170,7 @@ class RegularNamedTemporaryFile(object): """Like tempfile.NamedTemporaryFile which doesn't use O_TEMPORARY on windows """ def __init__(self, *args, **kws): - fd, self.name = tempfile.mkstemp() + fd, self.name = tempfile.mkstemp(**kws) try: self.file = os.fdopen(fd, *args, **kws) self.read = self.file.read