Skip to content

Commit

Permalink
dfu
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthIsUp committed Dec 29, 2017
1 parent f3f3195 commit 8ace524
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
2 changes: 0 additions & 2 deletions querybuilder/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def validation_format(self):

def validate_format(self, value):
if self.validation_format is not None:
print self.validation_format.match(value)
return bool(self.validation_format.match(value))

###########################################################################
Expand Down Expand Up @@ -447,7 +446,6 @@ class IntegerFilter(TypedFilter):
def validate_min(self, value):
min = self.validation.get('min')
if min is not None:
print(value, min, value >= min)
return value >= Decimal(str(min))

def validate_max(self, value):
Expand Down
11 changes: 5 additions & 6 deletions querybuilder/rules.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import (
absolute_import,
print_function,
)
from __future__ import absolute_import

# Standard Library
import json
from logging import getLogger

# Project Library
import sys

from querybuilder.constants import (
Conditions,
Inputs,
Expand Down Expand Up @@ -136,7 +135,7 @@ def is_valid(self, filters, indent=0, verbose=False):
# recurse and call is_valid for each rule in the list

log_args = '%s%s', pad, self.python_conditions[self.condition].__name__
print(log_args[0] % log_args[1:]) if verbose else logger.debug(*log_args)
sys.stderr.write(log_args[0] % log_args[1:] + '\n') if verbose else logger.debug(*log_args)

return self.python_conditions[self.condition](
rule.is_valid(filters, indent=indent + 2, verbose=verbose) for rule in self.rules
Expand All @@ -147,6 +146,6 @@ def is_valid(self, filters, indent=0, verbose=False):
result, filter_operand = filters.run_filter_for_rule(self)

log_args = '%s%s == %s', pad, self.__repr__(value=filter_operand), result
print(log_args[0] % log_args[1:]) if verbose else logger.debug(*log_args)
sys.stderr.write(log_args[0] % log_args[1:] + '\n') if verbose else logger.debug(*log_args)

return result
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ coverage==4.1
Sphinx==1.4.8
cryptography==1.7
PyYAML==3.11
pytest==2.9.2
pytest>=3.3.1,<4
pytest-runner==2.11.1
decorator
2 changes: 1 addition & 1 deletion tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@ def price(self):

def test_a_rule(scenario):
filters = SomeFilters(item=scenario.item)
assert scenario.is_valid == scenario.rule.is_valid(filters, verbose=1), scenario.reason
assert scenario.is_valid == scenario.rule.is_valid(filters, verbose=True), scenario.reason
25 changes: 20 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
[tox]
envlist = py27, py35, py36, flake8
envlist =
py{27,34,35,36}
flake8
dfu

[travis]
python =
3.6: py36
3.6: py36, dfu
3.5: py35
3.4: py34
2.7: py27
2.7: py27, dfu

[testenv:flake8]
basepython=python
deps=flake8
commands=flake8 querybuilder
deps=
flake8
dont-fudge-up
commands={envbindir}/python -m flake8 {posargs} querybuilder

[testenv:dfu]
; ensure that no debug code is left in
; see https://github.com/NorthIsUp/dont-fudge-up
basepython=python
deps=
flake8
dont-fudge-up
commands={envbindir}/python -m flake8 --select=D {posargs} querybuilder

[testenv]
setenv =
Expand All @@ -27,3 +41,4 @@ commands =
; requirements.txt with the pinned versions and uncomment the following lines:
; deps =
; -r{toxinidir}/requirements.txt

0 comments on commit 8ace524

Please sign in to comment.