forked from m-labs/pythonparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
35 lines (25 loc) · 864 Bytes
/
Copy pathtest_utils.py
File metadata and controls
35 lines (25 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# coding:utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
unicode = type("")
class BytesOnly(bytes):
def __new__(cls, s):
if isinstance(s, unicode):
s = s.encode()
return bytes.__new__(BytesOnly, s)
def __eq__(self, o):
return isinstance(o, bytes) and bytes.__eq__(self, o)
def __ne__(self, o):
return not self == o
class UnicodeOnly(unicode):
def __eq__(self, o):
return isinstance(o, unicode) and unicode.__eq__(self, o)
def __ne__(self, o):
return not self == o
try:
class LongOnly(long): # Python 2
def __eq__(self, o):
return isinstance(o, long) and long.__cmp__(self, o) == 0 # noqa
def __ne__(self, o):
return not self == o
except NameError: # Python 3
LongOnly = int