Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
random cleanups and make flake8 a test we run on every commit
- Loading branch information
|
@@ -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 |
|
|
|
@@ -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. |
|
@@ -170,6 +168,7 @@ |
|
|
# -- Options for LaTeX output -------------------------------------------------- |
|
|
|
|
|
latex_elements = { |
|
|
} |
|
|
# The paper size ('letterpaper' or 'a4paper'). |
|
|
#'papersize': 'letterpaper', |
|
|
|
|
@@ -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 |
|
@@ -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. |
|
|
|
@@ -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), |
|
|
} |
|
@@ -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 |
|
@@ -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 |
|
@@ -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 |
|
|
|
@@ -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"): |
|
@@ -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" |
|
|
|
|
@@ -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 ''")) == "" |
|
|
|
@@ -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") |
|
|
|
|
@@ -1,5 +1,3 @@ |
|
|
from topaz.objects.symbolobject import W_SymbolObject |
|
|
|
|
|
from ..base import BaseTopazTest |
|
|
|
|
|
|
|
|
|
|
@@ -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 |
|
|
|
|
@@ -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 |
|
@@ -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 |
|
|
|
@@ -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)), |
|
@@ -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)) |
|
|
]))) |
|
|
])) |
|
|
|
|
|
|
@@ -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") |
|
|