From 49632ac54eb809ac3663ed12ade78c4ece91ec3c Mon Sep 17 00:00:00 2001 From: Luca Giovenzana Date: Tue, 28 Aug 2018 20:09:20 +0200 Subject: [PATCH] Fixed import of redis in setup.py - redis was imported before being installed in setup.py - small setup refactor - pep8 corrections - installing dependencies project with pip on the setup.py - fixed travis to properly install test dependencies --- .travis.yml | 4 ++-- Makefile | 1 + RedisLibrary/RedisLibraryKeywords.py | 8 ++------ RedisLibrary/__init__.py | 4 ++-- RedisLibrary/version.py | 4 ---- VERSION | 1 + requirements.txt | 5 +---- setup.cfg | 2 +- setup.py | 24 ++++++++++++++++-------- 9 files changed, 26 insertions(+), 27 deletions(-) delete mode 100644 RedisLibrary/version.py create mode 100644 VERSION diff --git a/.travis.yml b/.travis.yml index 682dc2d..0712917 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: python python: - "3.6" -install: "pip install -r requirements.txt" -script: make clean coverage docs dist +install: "pip install ." +script: make clean test coverage docs dist deploy: provider: pypi user: nottyo diff --git a/Makefile b/Makefile index 95562ca..2da2980 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ test: ## run tests quickly with the default Python python setup.py test coverage: ## check code coverage quickly with the default Python + pip install coverage coverage run --source RedisLibrary setup.py test coverage report -m coverage html diff --git a/RedisLibrary/RedisLibraryKeywords.py b/RedisLibrary/RedisLibraryKeywords.py index ffd2ff4..01fbf67 100644 --- a/RedisLibrary/RedisLibraryKeywords.py +++ b/RedisLibrary/RedisLibraryKeywords.py @@ -1,18 +1,16 @@ # -*- coding: utf-8 -*- from robot.api import logger from robot.api.deco import keyword -from .version import VERSION import redis __author__ = 'Traitanit Huangsri' __email__ = 'traitanit.hua@gmail.com' -__version__ = VERSION class RedisLibraryKeywords(object): @keyword('Connect To Redis') - def connect_to_redis(self, redis_host, redis_port=6379, db=0): # pragma: no cover + def connect_to_redis(self, redis_host, redis_port=6379, db=0): # pragma: no cover """Connect to the Redis server. Arguments: @@ -166,7 +164,5 @@ def check_if_key_exits(self, redis_conn, key): | ${is_exist}= | Check If Key Exists | ${redis_conn} | BARCODE|1234567890 | """ if redis_conn.exists(key) is False: - logger.error("Key " + key +" doesn't exist in Redis.") + logger.error("Key " + key + " doesn't exist in Redis.") raise AssertionError - - diff --git a/RedisLibrary/__init__.py b/RedisLibrary/__init__.py index c10329d..76ac832 100644 --- a/RedisLibrary/__init__.py +++ b/RedisLibrary/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- +import pkg_resources # part of setuptools from .RedisLibraryKeywords import RedisLibraryKeywords -from .version import VERSION __author__ = 'Traitanit Huangsri' __email__ = 'traitanit.hua@gmail.com' -__version__ = VERSION +__version__ = pkg_resources.require("robotframework-redislibrary")[0].version class RedisLibrary(RedisLibraryKeywords): diff --git a/RedisLibrary/version.py b/RedisLibrary/version.py deleted file mode 100644 index 7d0fa31..0000000 --- a/RedisLibrary/version.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -VERSION = "0.2" diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..1d71ef9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.3 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2a0a435..54df888 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,2 @@ robotframework>=3.0 -coverage -tox -fakeredis==0.8.2 -redis==2.10.5 \ No newline at end of file +redis>=2.10.5 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 224a779..b88034e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -description-file = README.md \ No newline at end of file +description-file = README.md diff --git a/setup.py b/setup.py index 8741ba7..9669359 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,25 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import os from setuptools import setup -from RedisLibrary.version import VERSION -requirements = [ - 'tox', - 'coverage', - 'robotframework>=3.0', - 'redis>=2.10.5' -] + +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + + +def readlines(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).readlines() + + +version = read('VERSION') + +requirements = readlines('requirements.txt') test_requirements = [ + 'tox', + 'coverage', 'fakeredis==0.8.2' ] @@ -25,7 +33,7 @@ setup( name='robotframework-redislibrary', - version=VERSION, + version=version, description="robotframework-redislibrary is a Robot Framework test library for manipulating in-memory data which store in Redis", author="Traitanit Huangsri", author_email='traitanit.hua@gmail.com',