-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from jelmer/fix-windows
Fix parse_args test on Windows
- Loading branch information
Showing
1 changed file
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# Copyright (C) 2018 Jelmer Vernooij <[email protected]> | ||
# | ||
|
||
import os | ||
import tempfile | ||
import unittest | ||
from prometheus_xmpp.__main__ import parse_args | ||
|
@@ -18,17 +19,19 @@ def test_parse_args_env(self): | |
self.assertEqual(config['amtool_allowed'], ['[email protected]']) | ||
|
||
def test_parse_args_config(self): | ||
with tempfile.NamedTemporaryFile() as f: | ||
f.write(b"""\ | ||
f = tempfile.NamedTemporaryFile(delete=False) | ||
self.addCleanup(os.remove, f.name) | ||
f.write(b"""\ | ||
jid: foo@bar | ||
password: baz | ||
to_jid: [email protected] | ||
amtool_allowed: [email protected] | ||
""") | ||
f.flush() | ||
(jid, password_cb, recipients, config) = parse_args(['--config', f.name], env={}) | ||
f.flush() | ||
f.close() | ||
(jid, password_cb, recipients, config) = parse_args(['--config', f.name], env={}) | ||
|
||
self.assertTrue(jid.startswith('foo@bar/')) | ||
self.assertEqual(password_cb(), 'baz') | ||
self.assertEqual(recipients, ['[email protected]']) | ||
self.assertEqual(config['amtool_allowed'], ['[email protected]']) | ||
self.assertTrue(jid.startswith('foo@bar/')) | ||
self.assertEqual(password_cb(), 'baz') | ||
self.assertEqual(recipients, ['[email protected]']) | ||
self.assertEqual(config['amtool_allowed'], ['[email protected]']) |