11import instana .util
22import string
33from nose .tools import assert_equals
4+ import sys
5+
6+ if sys .version_info .major is 2 :
7+ string_types = basestring
8+ else :
9+ string_types = str
410
511
612def test_id_generation ():
@@ -72,15 +78,15 @@ def test_id_to_header_conversion():
7278 converted_id = instana .util .id_to_header (original_id )
7379
7480 # Assert that it is a string and there are no non-hex characters
75- assert isinstance (converted_id , basestring )
81+ assert isinstance (converted_id , string_types )
7682 assert all (c in string .hexdigits for c in converted_id )
7783
7884 # Test passing a standard Integer ID as a String
7985 original_id = instana .util .generate_id ()
8086 converted_id = instana .util .id_to_header (original_id )
8187
8288 # Assert that it is a string and there are no non-hex characters
83- assert isinstance (converted_id , basestring )
89+ assert isinstance (converted_id , string_types )
8490 assert all (c in string .hexdigits for c in converted_id )
8591
8692
@@ -89,21 +95,21 @@ def test_id_to_header_conversion_with_bogus_id():
8995 converted_id = instana .util .id_to_header ('' )
9096
9197 # Assert that it is a string and there are no non-hex characters
92- assert isinstance (converted_id , basestring )
98+ assert isinstance (converted_id , string_types )
9399 assert converted_id == ''
94100
95101 # Test passing a nil
96102 converted_id = instana .util .id_to_header (None )
97103
98104 # Assert that it is a string and there are no non-hex characters
99- assert isinstance (converted_id , basestring )
105+ assert isinstance (converted_id , string_types )
100106 assert converted_id == ''
101107
102108 # Test passing an Array
103109 converted_id = instana .util .id_to_header ([])
104110
105111 # Assert that it is a string and there are no non-hex characters
106- assert isinstance (converted_id , basestring )
112+ assert isinstance (converted_id , string_types )
107113 assert converted_id == ''
108114
109115
0 commit comments