File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ from oauth2cli .authcode import AuthCodeReceiver
4+
5+
6+ class TestAuthCodeReceiver (unittest .TestCase ):
7+ def test_setup_at_a_given_port_and_teardown (self ):
8+ port = 12345 # Assuming this port is available
9+ with AuthCodeReceiver (port = port ) as receiver :
10+ self .assertEqual (port , receiver .get_port ())
11+
12+ def test_setup_at_a_ephemeral_port_and_teardown (self ):
13+ port = 0
14+ with AuthCodeReceiver (port = port ) as receiver :
15+ self .assertNotEqual (port , receiver .get_port ())
16+
17+ def test_no_two_concurrent_receivers_can_listen_on_same_port (self ):
18+ port = 12345 # Assuming this port is available
19+ with AuthCodeReceiver (port = port ) as receiver :
20+ with self .assertRaises (OSError ):
21+ with AuthCodeReceiver (port = port ) as receiver2 :
22+ pass
23+
You can’t perform that action at this time.
0 commit comments