tests for windows, simplify pylint

This commit is contained in:
Alex Grintsvayg 2017-04-10 21:42:33 -04:00 committed by Alex Grintsvayg
parent 55d47b9f19
commit 7f7a6a619f
10 changed files with 85 additions and 52 deletions

View file

@ -17,13 +17,18 @@ environment:
clone_folder: c:\projects\lbry
test_script:
- cd C:\projects\lbry\
- pip install cython
- pip install mock pylint unqlite
- pylint lbrynet
- python -m twisted.trial tests # avoids having to set PYTHONPATH=. (see https://twistedmatrix.com/trac/ticket/9035)
#- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger
build_script:
- cd C:\projects\lbry\build\
- python set_version.py
- python set_build.py
- ps: .\build.ps1
- python zip_daemon.py
- python release_on_tag.py
artifacts:

View file

@ -65,7 +65,61 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating
disable=
anomalous-backslash-in-string,
arguments-differ,
attribute-defined-outside-init,
bad-continuation,
bare-except,
broad-except,
cell-var-from-loop,
consider-iterating-dictionary,
cyclic-import,
dangerous-default-value,
duplicate-code,
exec-used,
fixme,
global-statement,
inherit-non-class,
invalid-name,
locally-disabled,
logging-not-lazy,
missing-docstring,
multiple-imports,
no-init,
no-member,
no-self-use,
old-style-class,
pointless-string-statement,
protected-access,
redefined-builtin,
redefined-outer-name,
redefined-variable-type,
relative-import,
signature-differs,
singleton-comparison,
super-init-not-called,
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-nested-blocks,
too-many-public-methods,
too-many-return-statements,
too-many-statements,
trailing-newlines,
undefined-loop-variable,
ungrouped-imports,
unidiomatic-typecheck,
unnecessary-lambda,
unused-argument,
unused-variable,
useless-else-on-loop,
wildcard-import,
wrong-import-order,
wrong-import-position
[REPORTS]
@ -294,7 +348,8 @@ ignore-mixin-members=yes
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=twisted.internet.reactor,leveldb
ignored-modules=twisted.internet.reactor,leveldb,distutils
# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work

View file

@ -38,6 +38,6 @@ install:
script:
- pip install cython
- pip install mock pylint unqlite
- ./run_pylint.sh
- ./run_tests.sh
- pylint lbrynet
- PYTHONPATH=. trial tests
- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger

View file

@ -7,9 +7,9 @@ mingw32-make --version
# build/install miniupnpc manually
tar zxf miniupnpc-1.9.tar.gz
cd miniupnpc-1.9
mingw32-make.exe -f Makefile.mingw
python.exe setupmingw32.py build --compiler=mingw32
python.exe setupmingw32.py install
mingw32-make -f Makefile.mingw
python setupmingw32.py build --compiler=mingw32
python setupmingw32.py install
cd ..\
Remove-Item -Recurse -Force miniupnpc-1.9
@ -18,7 +18,13 @@ Get-Content ..\requirements.txt | Select-String -Pattern 'gmpy|miniupnpc' -NotMa
# add in gmpy wheel
Add-Content requirements.txt "./gmpy-1.17-cp27-none-win32.whl"
pip.exe install -r requirements.txt
pip install -r requirements.txt
python set_version.py
python set_build.py
pyinstaller -y daemon.onefile.spec
pyinstaller -y cli.onefile.spec
pyinstaller -y cli.onefile.spec
python zip_daemon.py
python release_on_tag.py

View file

@ -10,7 +10,7 @@ def main():
build = get_build()
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
with open(os.path.join(root_dir, 'lbrynet', 'build_type.py'), 'w') as f:
f.write('BUILD = "{}"'.format(build))
f.write("BUILD = '{}'\n".format(build))
def get_build():

View file

@ -239,9 +239,9 @@ class RequestHelper(object):
def _handle_incoming_blob(response_dict, peer, request):
if not request.response_identifier in response_dict:
if request.response_identifier not in response_dict:
return InvalidResponseError("response identifier not in response")
if not type(response_dict[request.response_identifier]) == dict:
if type(response_dict[request.response_identifier]) != dict:
return InvalidResponseError("response not a dict. got %s" %
type(response_dict[request.response_identifier]))
response = response_dict[request.response_identifier]
@ -255,14 +255,14 @@ def _handle_incoming_blob(response_dict, peer, request):
return InvalidResponseError("Got an unknown error from the peer: %s" %
(response['error'],))
else:
if not 'blob_hash' in response:
if 'blob_hash' not in response:
return InvalidResponseError("Missing the required field 'blob_hash'")
if not response['blob_hash'] == request.request_dict['requested_blob']:
return InvalidResponseError(
"Incoming blob does not match expected. Incoming: %s. Expected: %s" %
(response['blob_hash'], request.request_dict['requested_blob'])
)
if not 'length' in response:
if 'length' not in response:
return InvalidResponseError("Missing the required field 'length'")
if not request.blob.set_length(response['length']):
return InvalidResponseError("Could not set the length of the blob")
@ -358,7 +358,7 @@ class AvailabilityRequest(RequestHelper):
class PriceRequest(RequestHelper):
"""Ask a peer if a certain price is acceptable"""
def can_make_request(self):
if len(self.available_blobs) and not self.protocol in self.protocol_prices:
if len(self.available_blobs) and self.protocol not in self.protocol_prices:
return self.get_rate() is not None
return False

View file

@ -21,9 +21,6 @@ class DHTPeerFinder(object):
self.next_manage_call = None
def run_manage_loop(self):
from twisted.internet import reactor
self._manage_peers()
self.next_manage_call = reactor.callLater(60, self.run_manage_loop)

View file

@ -414,9 +414,6 @@ class AuthJSONRPCServer(AuthorizedBase):
return True
allowed_server, allowed_port = self.get_server_port(allowed_origin)
return (allowed_server, allowed_port) == (server, port)
return (
server == conf.settings['api_host'] and
port == conf.settings['api_port'])
def get_server_port(self, origin):
parsed = urlparse.urlparse(origin)

View file

@ -1,15 +0,0 @@
#! /bin/bash
set -eu
# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73
# TODO: as code quality improves, make pylint be more strict
pylint -E --disable=inherit-non-class --disable=no-member \
--ignored-modules=distutils \
--enable=unused-import \
--enable=bad-whitespace \
--enable=line-too-long \
--enable=trailing-whitespace \
--enable=missing-final-newline \
--enable=mixed-indentation \
lbrynet $@

View file

@ -1,12 +0,0 @@
#!/bin/bash
set -o xtrace
if [ -z "$@" ]; then
TESTS=tests
else
TESTS="$@"
fi
find -iname "*.pyc" -delete
PYTHONPATH=. trial $TESTS