forked from m-labs/pythonparser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_utils.py
More file actions
35 lines (26 loc) · 838 Bytes
/
Copy pathtest_utils.py
File metadata and controls
35 lines (26 loc) · 838 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
import sys
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
if sys.version_info >= (3,):
LongOnly = int
else:
class LongOnly(long):
def __eq__(self, o):
return isinstance(o, long) and long.__cmp__(self, o) == 0
def __ne__(self, o):
return not self == o