Skip to content

Commit

Permalink
random cleanups and make flake8 a test we run on every commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jun 16, 2013
1 parent 56e7e40 commit ed9d32c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 37 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
- secure: "VTXK/Lmi8DCoKIvg82QwlBtudV1XIRYjQbREew/ysCuvTlfp1mouZgvQQW8g\nYFNS3Ah1KTDD2qC0iZiYa7pvghlzP43M2VYr3iUxrRfiDEEIMX0jw3/n1+Sr\nWRdywivNMHhfYsEzEorW3mlwq3OmbBf4EG/UgX8c23GmW7MnwcQ="
matrix:
- TEST_TYPE=docs
- TEST_TYPE=flake8
- TEST_TYPE=own
- TEST_TYPE=translate
# - TEST_TYPE=rubyspec_untranslated
Expand Down
11 changes: 3 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down Expand Up @@ -170,6 +168,7 @@
# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
}
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

Expand All @@ -178,13 +177,11 @@

# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Topaz.tex', u'Topaz Documentation',
u'Alex Gaynor', 'manual'),
('index', 'Topaz.tex', u'Topaz Documentation', u'Alex Gaynor', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -227,9 +224,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Topaz', u'Topaz Documentation',
u'Alex Gaynor', 'Topaz', 'One line description of project.',
'Miscellaneous'),
('index', 'Topaz', u'Topaz Documentation', u'Alex Gaynor', 'Topaz', 'One line description of project.', 'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand Down
5 changes: 5 additions & 0 deletions tasks/travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ def run_docs_tests(env):
invoke.run("sphinx-build -W -b html docs/ docs/_build/")


def run_flake8_tests(env):
invoke.run('flake8 . --ignore="E122,E123,E124,E125,E126,E128,E501,F811"')


TEST_TYPES = {
"own": Test(run_own_tests, deps=["-r requirements.txt"]),
"rubyspec_untranslated": Test(run_rubyspec_untranslated, deps=["-r requirements.txt"], needs_rubyspec=True),
"translate": Test(run_translate_tests, deps=["-r requirements.txt"], needs_rubyspec=True, create_build=True),
"docs": Test(run_docs_tests, deps=["sphinx"], needs_rpython=False),
"flake8": Test(run_flake8_tests, deps=["flake8"], needs_rpython=False),
}
6 changes: 3 additions & 3 deletions tests/modules/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_sleep(self, space):

def test_trust(self, space):
w_res = space.execute("return 'a'.untrusted?")
assert self.unwrap(space, w_res) == False
assert self.unwrap(space, w_res) is False
w_res = space.execute("""
a = 'a'
a.untrust
Expand All @@ -236,7 +236,7 @@ def test_trust(self, space):

def test_taint(self, space):
w_res = space.execute("return 'a'.tainted?")
assert self.unwrap(space, w_res) == False
assert self.unwrap(space, w_res) is False
w_res = space.execute("""
a = 'a'
a.taint
Expand All @@ -253,7 +253,7 @@ def test_taint(self, space):

def test_freeze(self, space):
w_res = space.execute("return 'a'.frozen?")
assert self.unwrap(space, w_res) == False
assert self.unwrap(space, w_res) is False
w_res = space.execute("""
a = 'a'
a.freeze
Expand Down
5 changes: 3 additions & 2 deletions tests/objects/test_arrayobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_pop(self, space):
assert self.unwrap(space, space.execute("return [1, 2, 3].pop(2)")) == [2, 3]
assert self.unwrap(space, space.execute("return [1, 2, 3].pop(10)")) == [1, 2, 3]
assert self.unwrap(space, space.execute("return [].pop(1)")) == []
assert self.unwrap(space, space.execute("return [].pop")) == None
assert self.unwrap(space, space.execute("return [].pop")) is None
with self.raises(space, "ArgumentError"):
space.execute("[1].pop(-1)")
with self.raises(space, "TypeError"):
Expand Down Expand Up @@ -371,7 +371,7 @@ def test_sort(self, space):

def test_multiply(self, space):
w_res = space.execute("return [ 1, 2, 3 ] * 3")
assert self.unwrap(space, w_res) == [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
assert self.unwrap(space, w_res) == [1, 2, 3, 1, 2, 3, 1, 2, 3]
w_res = space.execute("return [ 1, 2, 3 ] * ','")
assert self.unwrap(space, w_res) == "1,2,3"

Expand All @@ -392,6 +392,7 @@ def test_flatten(self, space):
a.flatten
""")


class TestArrayPack(BaseTopazTest):
def test_garbage_format(self, space):
assert space.str_w(space.execute("return [].pack ''")) == ""
Expand Down
2 changes: 1 addition & 1 deletion tests/objects/test_methodobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_to_s(self, space):

def test_allocate(self, space):
with self.raises(space, "TypeError", "allocator undefined for UnboundMethod"):
w_res = space.execute("return UnboundMethod.allocate")
space.execute("return UnboundMethod.allocate")

def test_owner(self, space):
w_res = space.execute("return 'test'.method(:to_s).owner")
Expand Down
2 changes: 0 additions & 2 deletions tests/objects/test_rangeobject.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from topaz.objects.symbolobject import W_SymbolObject

from ..base import BaseTopazTest


Expand Down
9 changes: 2 additions & 7 deletions tests/test_interpreter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import math

import pytest

from topaz.modules.kernel import Kernel
from topaz.objects.boolobject import W_TrueObject
from topaz.objects.moduleobject import W_ModuleObject
from topaz.objects.objectobject import W_Object, W_BaseObject

from .base import BaseTopazTest

Expand Down Expand Up @@ -930,7 +925,7 @@ def self.get; @@foo; end

def test_class_variable_access_has_static_scope(self, space):
with self.raises(space, "NameError"):
w_res = space.execute("""
space.execute("""
class A
def get
@@foo
Expand Down Expand Up @@ -1623,7 +1618,7 @@ def f
assert self.unwrap(space, w_res) == ["begin", "ensure", "begin", "begin_end", "ensure", "after", "begin", "ensure"]

def test_break_block_frame_exited(self, space):
w_res = space.execute("""
space.execute("""
def create_block
b = capture_block do
break
Expand Down
4 changes: 2 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def test_while(self, space):
""")
assert res == ast.Main(ast.Block([
ast.Statement(ast.Assignment(ast.Variable("i", 2), ast.ConstantInt(0))),
ast.Statement(ast.While(ast.Send(ast.Variable("i", 3), "<", [ast.ConstantInt(10)], None, 3), ast.Block([
ast.Statement(ast.While(ast.Send(ast.Variable("i", 3), "<", [ast.ConstantInt(10)], None, 3), ast.Block([
ast.Statement(ast.Send(ast.Self(4), "puts", [ast.Variable("i", 4)], None, 4)),
ast.Statement(ast.Send(ast.Self(5), "puts", [ast.ConstantInt(1)], None, 5)),
ast.Statement(ast.Send(ast.Self(6), "puts", [ast.Variable("i", 6)], None, 6)),
Expand Down Expand Up @@ -867,7 +867,7 @@ def test_def(self, space):

assert space.parse("def f(a, b) a + b end") == ast.Main(ast.Block([
ast.Statement(ast.Function(None, "f", [ast.Argument("a"), ast.Argument("b")], None, None, ast.Block([
ast.Statement(ast.Send(ast.Variable("a", 1), "+", [ast.Variable("b", 1)], None, 1))
ast.Statement(ast.Send(ast.Variable("a", 1), "+", [ast.Variable("b", 1)], None, 1))
])))
]))

Expand Down
17 changes: 5 additions & 12 deletions topaz/utils/regexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,18 +1237,11 @@ def _parse_posix_class(source, info):


def _compile_no_cache(pattern, flags):
global_flags = flags
while True:
source = Source(pattern)
if flags & EXTENDED:
source.ignore_space = True
info = Info(flags)
try:
parsed = _parse_pattern(source, info)
except UnscopedFlagSet as e:
global_flags = e.flags | flags
else:
break
source = Source(pattern)
if flags & EXTENDED:
source.ignore_space = True
info = Info(flags)
parsed = _parse_pattern(source, info)

if not source.at_end():
raise RegexpError("trailing characters in pattern")
Expand Down

0 comments on commit ed9d32c

Please sign in to comment.