Skip to content

Commit 8bd236c

Browse files
author
Ian C
committed
Merge pull request #80 from GrappigPanda/unit_tests
Resolves #79, #72, #67, #52
2 parents e29f382 + 1cac12a commit 8bd236c

File tree

8 files changed

+43
-4
lines changed

8 files changed

+43
-4
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dist*
22
build*
33
.idea*
4-
*.pyc
4+
*.pyc
5+
*.swp

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: python
2+
python:
3+
- "2.6"
4+
- "2.7"
5+
6+
before_script:
7+
- virtualenv ../venv
8+
- source ../venv/bin/activate
9+
- pip install -r requirements.txt
10+
script:
11+
- nose2

pyg/Pygemony.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ def file_handler(self):
7474
file_type = detect_mimetype(file_)
7575
# We're looking for startswith('text/'). Mimetype returns
7676
# None if it can't determine file type. Remove if either is True
77-
if file_type[0].startswith("application") or file_type[0] is None:
78-
files_found.remove(file_)
77+
try:
78+
if file_type[0].startswith("application") or file_type[0] is None:
79+
files_found.remove(file_)
80+
except (AttributeError, IndexError) as e:
81+
print "Failed to open file {} with error of {}".format(file_, e)
7982

8083
for file_ in files_found:
8184
try:
@@ -94,6 +97,7 @@ def lookup_language(self):
9497
lang_map = {'cpp': LanguageCPP,
9598
'python': LanguagePython,
9699
'javascript': LanguageJavascript,
97-
'c': LanguageC}
100+
'c': LanguageC,
101+
'go': LanguageGo}
98102
langs = [i for i in self.github.get_languages()]
99103
return [lang_map[str(langs[0][0]).lower()]()]

pyg/languages.py

+8
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ def __init__(self):
2929
self.multi_comment = ['/*', '*/']
3030
self.file_exts = ['*.js', '.node']
3131
self.ignore = ['node_modules']
32+
33+
class LanguageGo:
34+
def __init__(self):
35+
self.single_comment = '//'
36+
self.multi_comment = ['/*', '*/']
37+
self.file_exts = ['*.go']
38+
self.ignore = []
39+

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
github3.py==0.9.5
22
requests==2.9.1
3+
mock==1.3.0
34
uritemplate.py==0.3.0
45
wheel==0.24.0
6+
nose2==0.5.0

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def read(fname):
77

88
setup(
99
name='pygemony',
10+
install_requires=read('requirements.txt'),
1011
version='0.0.1a',
1112
description=('Parse TODO from github directory'),
1213
license="MIT",

unit_tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

unit_tests/test_pygemony.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from mock import patch
2+
3+
import unittest
4+
5+
from pyg.Pygemony import Pygemony
6+
7+
class PygemonyTestCase(unittest.TestCase):
8+
9+
def test_hashing_pass(self):
10+
md5 = Pygemony.hash_todo("# TODO(ian): Testing 123", 5, 'test.py')
11+
self.assertEqual(md5, "3ce18a4c1ef5500be307fd49bae6a37e")

0 commit comments

Comments
 (0)