forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbase.py
More file actions
74 lines (56 loc) · 1.72 KB
/
Copy pathbase.py
File metadata and controls
74 lines (56 loc) · 1.72 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import sys
import unittest
import github3
from expecter import expect, add_expectation
class BaseTest(unittest.TestCase):
api = 'https://api.github.com/'
kr = 'kennethreitz'
sigm = 'sigmavirus24'
todo = 'Todo.txt-python'
gh3py = 'github3py'
test_repo = 'github3.py_test'
def __init__(self, methodName='runTest'):
super(BaseTest, self).__init__(methodName)
self.auth = False
user = self.user = os.environ.get('__USER')
pw = self.pw = os.environ.get('__PASS')
self.g = github3.GitHub()
if user and pw:
self._g = github3.login(self.user, self.pw)
self.auth = True
def assertIsNotNone(self, value, msg=None):
if sys.version_info >= (2, 7):
super(BaseTest, self).assertIsNotNone(value, msg)
else:
try:
assert value is not None
except AssertionError:
self.fail(msg)
def assertAreNotNone(self, obj, *attrs):
"""Assert the attributes of the object are not none"""
for attr in attrs:
self.assertIsNotNone(getattr(obj, attr),
'{0} is None'.format(attr))
def expect_list_of_class(self, l, cls):
for i in l:
expect(i).isinstance(cls)
def is_not_None(var):
return var is not None
def is_None(var):
return var is None
def is_True(var):
return var is True
def is_False(var):
return var is False
add_expectation(is_not_None)
add_expectation(is_None)
add_expectation(is_True)
add_expectation(is_False)
if sys.version_info >= (3, 0):
str_test = (str, bytes)
else:
str_test = (str, unicode)
def expect_str(val):
expect(val).isinstance(str_test)
expect(val) != ''