-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-28009: Fix uuid.uuid1() and uuid.get_node() on AIX #8672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4ed41e9
ba47933
c6029a4
7e1874d
6a5bccb
a98309b
53ef750
6fd5f8e
3bb1c08
1af8e3d
d3eaab9
3469a01
399e8ec
6e2a9bf
bb3a460
db6767f
25d3ef1
fa9b43b
4a0c8f0
6463707
a0ef760
095e221
ec4c0e8
70a45f0
b1b4952
8f0687a
4756670
c55714a
10f272e
27b6c32
33969b9
7a57734
4628cea
d2830a2
0688727
ff1ee20
083e9c6
30cd017
27a972b
543e66d
588fda7
28f7a01
6fc2129
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…e getnode() Move _netstat_getnode() find alg so that it can be tested using unittest.mock Add new test `test_uuid/find_mac_netstat` for AIX and netstat
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,8 +325,7 @@ def test_uuid1_eui64(self): | |
| with unittest.mock.patch.multiple( | ||
| self.uuid, | ||
| _node=None, # Ignore any cached node value. | ||
| _NODE_GETTERS_WIN32=[too_large_getter], | ||
| _NODE_GETTERS_UNIX=[too_large_getter], | ||
| _NODE_GETTERS=[too_large_getter], | ||
| ): | ||
| node = self.uuid.getnode() | ||
| self.assertTrue(0 < node < (1 << 48), '%012x' % node) | ||
|
|
@@ -516,21 +515,39 @@ class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase): | |
| class BaseTestInternals: | ||
| uuid = None | ||
|
|
||
| @unittest.skipUnless(AIX, 'requires AIX') | ||
| def test_find_mac_netstat(self): | ||
| data = '''Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll | ||
| en0 1500 link#2 fe.ad.c.1.23.4 1714807956 0 711348489 0 0 | ||
| 01:00:5e:00:00:01 | ||
| en0 1500 192.168.129 x071 1714807956 0 711348489 0 0 | ||
| 224.0.0.1 | ||
| en0 1500 192.168.90 x071 1714807956 0 711348489 0 0 | ||
| 224.0.0.1 | ||
| ''' | ||
| popen = unittest.mock.MagicMock() | ||
| popen.stdout = io.BytesIO(data.encode()) | ||
|
|
||
| with unittest.mock.patch.object(shutil, 'which', | ||
| return_value='/usr/bin/netstat'): | ||
| with unittest.mock.patch.object(subprocess, 'Popen', | ||
| return_value=popen): | ||
| mac = self.uuid._find_mac_netstat( | ||
| command='netstat', | ||
| args='-ia', | ||
| hw_identifiers=b'Address', | ||
| get_index=lambda x: x * 1, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why you need to use i+1 here. It looks like a bug.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess my replies did not make it here. |
||
| ) | ||
|
|
||
| self.assertEqual(mac, 0xfead0c012304) | ||
|
aixtools marked this conversation as resolved.
|
||
|
|
||
| @unittest.skipUnless(os.name == 'posix', 'requires Posix') | ||
| @unittest.skipIf(AIX, 'because AIX "ifconfig" does not provide macaddr') | ||
|
aixtools marked this conversation as resolved.
Outdated
|
||
| def test_find_mac(self): | ||
| if not AIX: | ||
| data = ''' | ||
| fake hwaddr | ||
| data = '''fake Link encap:UNSPEC hwaddr 00-00 | ||
|
aixtools marked this conversation as resolved.
Outdated
|
||
| cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 | ||
| eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab | ||
| ''' | ||
| else: | ||
| data = ''' | ||
| fake hwaddr | ||
| cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 | ||
| eth0 Link encap:Ethernet HWaddr 12.34.56.78.90.ab | ||
| ''' | ||
|
|
||
| popen = unittest.mock.MagicMock() | ||
| popen.stdout = io.BytesIO(data.encode()) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.