Skip to content

Commit

Permalink
Merge 36babae into df0fc08
Browse files Browse the repository at this point in the history
  • Loading branch information
ttoocs committed Jan 4, 2018
2 parents df0fc08 + 36babae commit c2a6d8c
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 2 deletions.
4 changes: 2 additions & 2 deletions horizons/main.py
Expand Up @@ -64,7 +64,7 @@
"""
Following are a list of global variables. Their scope is this module.
Since this is not a class, in each function where these variables are
referenced, they need to be declared with 'global' keyword.
referenced, they need to be declared with 'global' keyword.
See: http://python-textbok.readthedocs.io/en/1.0/Variables_and_Scope.html
"""
Expand Down Expand Up @@ -596,7 +596,7 @@ def set_debug_log(enabled, startup=False):
@param startup: True if on startup to apply settings. Won't show popup
"""
global gui, command_line_arguments

options = command_line_arguments

if enabled: # enable logging
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Expand Up @@ -30,10 +30,12 @@
def pytest_addoption(parser):
parser.addoption('--long-tests', action='store_true', help='include long-running tests')
parser.addoption('--gui-tests', action='store_true', help='include gui tests')
parser.addoption('--fixme-fail-tests', action='store_true', help='fail on fixme')


def pytest_configure(config):
config.addinivalue_line('markers', 'long: mark test as long-running')
config.addinivalue_line('markers', 'fixme: mark test as known-broken')


def pytest_runtest_setup(item):
Expand All @@ -50,6 +52,10 @@ def pytest_runtest_setup(item):
if marker is not None and not item.config.getoption('--gui-tests'):
pytest.skip('test is gui test')

marker = item.get_marker("fixme")
if marker is not None and not item.config.getoption('--fixme-fail-tests'):
pytest.xfail("Expecting failure")


# Basic test setup, installs global mock for fife so we can run gui/game tests.
#
Expand Down
10 changes: 10 additions & 0 deletions tests/gui/ingame/test_boatbuilder.py
Expand Up @@ -19,12 +19,15 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from horizons.constants import BUILDINGS, PRODUCTION, UNITS
from horizons.world.production.producer import Producer
from tests.gui import gui_test
from tests.gui.helper import saveload


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1224(gui):
"""
Expand Down Expand Up @@ -59,6 +62,7 @@ def running_costs():
assert running_costs() == '25', "Expected 25, got {}".format(running_costs())


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1294(gui):
"""
Expand Down Expand Up @@ -98,6 +102,7 @@ def test_ticket_1294(gui):
gui.run()


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1830(gui):
"""
Expand Down Expand Up @@ -135,6 +140,7 @@ def test_ticket_1830(gui):
assert len(producer.production_queue) == 1


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=60)
def test_remove_from_queue(gui):
"""
Expand All @@ -160,6 +166,7 @@ def test_remove_from_queue(gui):
gui.trigger('UB_main_tab/queue_elem_0')


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=60)
def test_cancel_ticket_1424(gui):
"""
Expand Down Expand Up @@ -187,6 +194,7 @@ def test_cancel_ticket_1424(gui):
gui.trigger('UB_main_tab/UB_cancel_button')


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=60)
def test_save_load_ticket_1421(gui):
"""
Expand All @@ -212,6 +220,7 @@ def test_save_load_ticket_1421(gui):
saveload(gui)


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1513(gui):
"""
Expand Down Expand Up @@ -254,6 +263,7 @@ def running_costs():
assert running_costs() == '10', "Expected 10, got {}".format(running_costs())


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1514(gui):
"""
Expand Down
19 changes: 19 additions & 0 deletions tests/gui/ingame/test_bugs.py
Expand Up @@ -19,6 +19,8 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from horizons.command.building import Tear
from horizons.command.unit import CreateUnit
from horizons.component.storagecomponent import StorageComponent
Expand All @@ -29,6 +31,7 @@
from tests.gui.helper import found_settlement, get_player_ship, move_ship


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1352(gui):
"""
Expand All @@ -51,6 +54,7 @@ def test_ticket_1352(gui):
gui.select([ship])


@pytest.mark.fixme()
@gui_test(use_dev_map=True, ai_players=3, timeout=120)
def test_ticket_1368(gui):
"""
Expand All @@ -70,6 +74,7 @@ def test_ticket_1368(gui):
gui.select([ai_warehouse])


@pytest.mark.fixme()
@gui_test(use_fixture='ai_settlement', timeout=60)
def test_ticket_1369(gui):
"""
Expand Down Expand Up @@ -106,6 +111,7 @@ def test_ticket_1369(gui):
# assert gui.find(name='overview_trade_ship')


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1362(gui):
"""
Expand All @@ -128,6 +134,7 @@ def func():
gui.press_key(gui.Key.F5)


@pytest.mark.fixme()
@gui_test(use_fixture='plain', timeout=120)
def test_ticket_1371(gui):
"""
Expand Down Expand Up @@ -170,6 +177,7 @@ def test_ticket_1371(gui):
assert gui.find(name='overview_buildrelated')


@pytest.mark.fixme()
@gui_test(use_fixture='fife_exception_not_found', timeout=60)
def test_ticket_1447(gui):
"""
Expand All @@ -195,6 +203,7 @@ def test_ticket_1447(gui):
gui.run()


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1515(gui):
"""
Expand All @@ -204,6 +213,7 @@ def test_ticket_1515(gui):
gui.cursor_click(6, 17, 'left')


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1520(gui):
"""
Expand Down Expand Up @@ -233,6 +243,7 @@ def test_ticket_1520(gui):
gui.cursor_release_button(13, 11, 'left')


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1509(gui):
"""
Expand All @@ -257,6 +268,7 @@ def test_ticket_1509(gui):
gui.trigger('tab_base/1')


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1526(gui):
"""
Expand All @@ -272,6 +284,7 @@ def test_ticket_1526(gui):
gui.cursor_click(52, 12, 'left', ctrl=True)


@pytest.mark.fixme()
@gui_test(use_fixture='plain', timeout=120)
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
"""
Expand Down Expand Up @@ -299,6 +312,7 @@ def test_pavilion_build_crash_built_via_settler_related_tab(gui):
# if we survive until here, the bug hasn't happened


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=120)
def test_ticket_1848(gui):
"""Settlement production overview crashes if ships were produced"""
Expand All @@ -320,6 +334,7 @@ def test_ticket_1848(gui):
gui.trigger('tab_account/show_production_overview')


@pytest.mark.fixme()
@gui_test(use_fixture='plain')
def test_ticket_1948(gui):
"""Triggers a crash that happens when building a storage tent on the border of the settlement"""
Expand All @@ -336,6 +351,7 @@ def test_ticket_1948(gui):
gui.cursor_click(37, 20, 'left')


@pytest.mark.fixme()
@gui_test(use_fixture='fife_exception_not_found', timeout=60)
def test_ticket_2117(gui):
"""Changing language with active production overview tab crashes game"""
Expand All @@ -353,6 +369,7 @@ def test_ticket_2117(gui):
gui.trigger('settings_window/okButton')


@pytest.mark.fixme()
@gui_test(use_dev_map=True)
def test_ticket_2419(gui):
"""Game crashes when setting speed to zero and pressing pause twice"""
Expand All @@ -362,6 +379,7 @@ def test_ticket_2419(gui):
gui.press_key(gui.Key.P)


@pytest.mark.fixme()
@gui_test(use_dev_map=True)
def test_ticket_2475(gui):
"""Game crashes when two resources are produced in the same tick and the production
Expand Down Expand Up @@ -389,6 +407,7 @@ def test_ticket_2475(gui):
producer.on_production_finished({RES.BOARDS: 1})


@pytest.mark.fixme()
@gui_test(use_dev_map=True)
def test_ticket_2500(gui):
"""Game crashes when exiting the game while the building tool is still active."""
Expand Down
3 changes: 3 additions & 0 deletions tests/gui/ingame/test_build.py
Expand Up @@ -21,13 +21,16 @@

import time

import pytest

from horizons.component.collectingcomponent import CollectingComponent
from horizons.constants import BUILDINGS
from horizons.world.units.collectors.collector import Collector
from tests.gui import gui_test
from tests.gui.helper import found_settlement


@pytest.mark.fixme()
@gui_test(use_fixture='plain', timeout=60)
def test_found_settlement(gui):
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/gui/ingame/test_dialogs.py
Expand Up @@ -19,11 +19,14 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from horizons.component.namedcomponent import NamedComponent
from tests.gui import gui_test
from tests.gui.helper import get_player_ship


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=60)
def test_change_name(gui):
"""Rename a ship."""
Expand All @@ -48,6 +51,7 @@ def rename():
assert new_name == 'Dagobert'


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=60)
def test_change_name_empty_not_allowed(gui):
"""Make sure an object's name can't be changed to some empty string.
Expand Down Expand Up @@ -82,6 +86,7 @@ def rename_spaces():
assert old_name == new_name


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=60)
def test_chat(gui):
"""Opens chat dialog.
Expand Down
3 changes: 3 additions & 0 deletions tests/gui/ingame/test_diplomacy.py
Expand Up @@ -19,9 +19,12 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from tests.gui import gui_test


@pytest.mark.fixme()
@gui_test(use_dev_map=True, ai_players=1)
def test_diplomacy(gui):
"""Test changing diplomacy status."""
Expand Down
4 changes: 4 additions & 0 deletions tests/gui/ingame/test_generated.py
Expand Up @@ -21,10 +21,13 @@

import itertools

import pytest

from tests.gui import gui_test
from tests.gui.helper import get_player_ship


@pytest.mark.fixme()
@gui_test(use_fixture='plain', timeout=120)
def test_build_a_settlement(gui):
"""
Expand Down Expand Up @@ -104,6 +107,7 @@ def test_build_a_settlement(gui):
gui.cursor_click(58, 5, 'left')


@pytest.mark.fixme()
@gui_test(use_fixture='plain', timeout=120)
def test_buildingtool(gui):
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/gui/ingame/test_hud.py
Expand Up @@ -19,9 +19,12 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from tests.gui import gui_test


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=60)
def test_hud(gui):
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/gui/ingame/test_keys.py
Expand Up @@ -19,9 +19,12 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from tests.gui import gui_test


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=120)
def test_ticket_1342(gui):
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/gui/ingame/test_logbook.py
Expand Up @@ -19,9 +19,12 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ###################################################

import pytest

from tests.gui import gui_test


@pytest.mark.fixme()
@gui_test(use_dev_map=True, timeout=60)
def test_logbook(gui):
"""
Expand All @@ -38,6 +41,7 @@ def test_logbook(gui):
assert gui.find(name='captains_log') is None


@pytest.mark.fixme()
@gui_test(use_fixture='boatbuilder', timeout=60)
def test_logbook_statistics(gui):
"""Open the 3 three different statistic tabs in the logbook."""
Expand Down

0 comments on commit c2a6d8c

Please sign in to comment.