Skip to content

Commit

Permalink
Merge pull request #92 from jelmer/fix-windows
Browse files Browse the repository at this point in the history
Fix parse_args test on Windows
  • Loading branch information
jelmer authored Sep 18, 2024
2 parents 726bc89 + 14596a8 commit 464070a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (C) 2018 Jelmer Vernooij <[email protected]>
#

import os
import tempfile
import unittest
from prometheus_xmpp.__main__ import parse_args
Expand All @@ -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]'])

0 comments on commit 464070a

Please sign in to comment.