Skip to content

Commit

Permalink
Merge 5004b9e into 232de79
Browse files Browse the repository at this point in the history
  • Loading branch information
arcivanov committed Oct 9, 2022
2 parents 232de79 + 5004b9e commit 02d2cc6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
71 changes: 71 additions & 0 deletions src/integrationtest/python/issue_868_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2022 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import textwrap
import unittest

from itest_support import IntegrationTestSupport
from pybuilder.core import Logger
from pybuilder.errors import BuildFailedException


class Issue868Test(IntegrationTestSupport):
def test(self):
self.write_build_file(textwrap.dedent("""
from pybuilder.core import init, use_plugin
use_plugin("python.core")
use_plugin("python.integrationtest")
name = "issue_868_tests"
@init
def init(project):
project.set_property("integrationtest_breaks_build", True)
"""))

self.create_directory("src/main/python/code")
self.create_directory("src/integrationtest/python")

self.write_file("src/main/python/code/__init__.py", textwrap.dedent(
"""
def return_one():
return 1
"""
))
self.write_file("src/integrationtest/python/code_tests.py", textwrap.dedent(
"""
import unittest
import code
class CodeTests(unittest.TestCase):
def test_failure(self):
print("Failure")
self.assertEqual(0, 1)
if __name__ == "__main__":
unittest.main()
"""))

reactor = self.prepare_reactor(log_level=Logger.WARN)
with self.assertRaises(BuildFailedException):
reactor.build("run_integration_tests")


if __name__ == "__main__":
unittest.main()
5 changes: 3 additions & 2 deletions src/main/python/pybuilder/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,6 @@ def print_error_line(text=""):
def print_file_content(file_name, line_prefix=" "):
print_text_line("File {0}:".format(file_name))

for line in open(file_name):
print_text(line_prefix + line)
with open(file_name) as f:
for line in f:
print_text(line_prefix + line)

0 comments on commit 02d2cc6

Please sign in to comment.