Skip to content

Commit 4e0dd40

Browse files
committed
fix further flake8 errors
1 parent 2de2ef1 commit 4e0dd40

9 files changed

+24
-22
lines changed

.travis.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ language: python
22
matrix:
33
include:
44
- python: "2.7"
5-
env: NOSE_IGNORE_FILES=test_py3_sugar.py
5+
env: NOSE_IGNORE_FILES=test_py3_sugar.py FLAKE8_EXCLUDE_ARG=docs,test_py3_sugar.py
66
- python: "3.4"
7+
env: FLAKE8_EXCLUDE_ARG=docs
78
- python: "3.5"
9+
env: FLAKE8_EXCLUDE_ARG=docs
810
- python: "3.6"
11+
env: FLAKE8_EXCLUDE_ARG=docs
912
services: mongodb
1013
install:
1114
- pip install -r requirements-test.txt
1215
script:
13-
- "flake8"
16+
- "flake8 --exclude ${FLAKE8_EXCLUDE_ARG}"
1417
- "NANOMONGO_SKIP_MOTOR=1 nosetests"

nanomongo/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __getattribute__(self, key):
183183
return super(DotNotationMixin, self).__getattribute__(key)
184184
try:
185185
return self.__getitem__(key)
186-
except:
186+
except KeyError:
187187
return
188188

189189
return super(DotNotationMixin, self).__getattribute__(key)

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[flake8]
22
ignore = E501
3-
exclude =
4-
docs
5-
63

74
[nosetests]
85
verbosity=2

test/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pymongo
2+
3+
PYMONGO_CLIENT = pymongo.MongoClient(serverSelectionTimeoutMS=500)
4+
5+
try:
6+
PYMONGO_CLIENT.admin.command('ismaster')
7+
except pymongo.errors.ServerSelectionTimeoutError:
8+
PYMONGO_CLIENT = None

test/test_document_motor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
try:
1414
import motor
1515
MOTOR_CLIENT = motor.MotorClient()
16-
except:
16+
except ImportError:
1717
MOTOR_CLIENT = None
1818

1919
SKIP_MOTOR = bool(os.environ.get('NANOMONGO_SKIP_MOTOR'))

test/test_field.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import datetime
33
import unittest
44

5-
import six
6-
75
from bson import DBRef
6+
import six
87

98
from nanomongo.field import Field
109
from nanomongo.errors import ValidationError

test/test_py3_sugar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pymongo
88
pymongo.MongoClient()
99
PYMONGO_OK = True
10-
except:
10+
except ImportError:
1111
PYMONGO_OK = False
1212

1313

test/test_util.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22

33
from mock import patch
4+
import pymongo
45

56
from nanomongo.field import Field
67
from nanomongo.document import BaseDocument
@@ -10,16 +11,12 @@
1011
)
1112
from nanomongo.errors import ValidationError
1213

13-
try:
14-
import pymongo
15-
PYMONGO_CLIENT = pymongo.MongoClient()
16-
except:
17-
PYMONGO_CLIENT = False
14+
PYMONGO_CLIENT = pymongo.MongoClient()
1815

1916
try:
2017
import motor
2118
MOTOR_CLIENT = motor.MotorClient()
22-
except:
19+
except ImportError:
2320
MOTOR_CLIENT = None
2421

2522

test/test_zexamples.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from __future__ import unicode_literals
2-
import six
32
import unittest
43

4+
import pymongo
5+
import six
6+
57
from examples.example import User, Entry
68

7-
try:
8-
import pymongo
9-
PYMONGO_CLIENT = pymongo.MongoClient()
10-
except:
11-
PYMONGO_CLIENT = False
9+
PYMONGO_CLIENT = pymongo.MongoClient()
1210

1311

1412
class HelperFuncionsTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)