示例#1
0
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            case.assertAlmostEqual(boost.boost_usage, boost_value, delta=1)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_USED"] +
            get_specific_replays()["0_BOOST_USED"],
            answers=get_specific_answers()["BOOST_USED"] +
            get_specific_answers()["0_BOOST_USED"],
            cache=replay_cache)

    def test_boost_feathered(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            assertNearlyEqual(case, boost.boost_usage, boost_value, percent=3)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_FEATHERED"],
            answers=get_specific_answers()["BOOST_FEATHERED"],
            cache=replay_cache)
示例#2
0
import unittest

import numpy as np

import basetest_dqn_like as base
from basetest_training import _TestBatchTrainingMixin
import pfrl
from pfrl.agents import categorical_dqn
from pfrl.agents.categorical_dqn import compute_value_loss
from pfrl.agents.categorical_dqn import compute_weighted_value_loss
from pfrl.agents import CategoricalDQN

import torch
import pytest

assertions = unittest.TestCase("__init__")


def _apply_categorical_projection_naive(y, y_probs, z):
    """Naively implemented categorical projection for checking results.

    See (7) in https://arxiv.org/abs/1802.08163.
    """
    batch_size, n_atoms = y.shape
    assert z.shape == (n_atoms, )
    assert y_probs.shape == (batch_size, n_atoms)
    v_min = z[0]
    v_max = z[-1]
    proj_probs = np.zeros((batch_size, n_atoms), dtype=np.float32)
    for b in range(batch_size):
        for i in range(n_atoms):
示例#3
0
    def test_convenience(self):

        test_layout = (""" ##################
            #a#.  .  # .     #
            #b#####    ####x #
            #     . #  .  #y##
            ################## """)

        player_0 = StoppingPlayer()
        player_1 = SteppingPlayer('^<')
        player_2 = StoppingPlayer()
        player_3 = StoppingPlayer()
        teams = [
            SimpleTeam(player_0, player_2),
            SimpleTeam(player_1, player_3)
        ]
        game_master = GameMaster(test_layout, teams, 4, 2, noise=False)
        universe = datamodel.CTFUniverse._from_json_dict(
            game_master.game_state)
        game_master.set_initial()

        assert universe.bots[0] == player_0.me
        assert universe.bots[1] == player_1.me
        assert universe.bots[2] == player_2.me
        assert universe.bots[3] == player_3.me

        assert universe == player_1.current_uni
        assert [universe.bots[0]] == player_2.other_team_bots
        assert [universe.bots[1]] == player_3.other_team_bots
        assert [universe.bots[2]] == player_0.other_team_bots
        assert [universe.bots[3]] == player_1.other_team_bots
        assert [universe.bots[i] for i in (0, 2)] == player_0.team_bots
        assert [universe.bots[i] for i in (1, 3)] == player_0.enemy_bots
        assert [universe.bots[i] for i in (1, 3)] == player_1.team_bots
        assert [universe.bots[i] for i in (0, 2)] == player_1.enemy_bots
        assert [universe.bots[i] for i in (0, 2)] == player_2.team_bots
        assert [universe.bots[i] for i in (1, 3)] == player_2.enemy_bots
        assert [universe.bots[i] for i in (1, 3)] == player_3.team_bots
        assert [universe.bots[i] for i in (0, 2)] == player_3.enemy_bots

        assert player_1.current_pos == (15, 2)
        assert player_1.initial_pos == (15, 2)
        assert universe.bots[1].current_pos == (15, 2)
        assert universe.bots[1].initial_pos == (15, 2)

        assert universe.teams[0] == player_0.team
        assert universe.teams[0] == player_2.team
        assert universe.teams[1] == player_1.team
        assert universe.teams[1] == player_3.team

        assert universe.teams[1] == player_0.enemy_team
        assert universe.teams[1] == player_2.enemy_team
        assert universe.teams[0] == player_1.enemy_team
        assert universe.teams[0] == player_3.enemy_team

        unittest.TestCase().assertCountEqual(
            player_0.enemy_food, universe.enemy_food(player_0.team.index))
        unittest.TestCase().assertCountEqual(
            player_1.enemy_food, universe.enemy_food(player_1.team.index))
        unittest.TestCase().assertCountEqual(
            player_2.enemy_food, universe.enemy_food(player_2.team.index))
        unittest.TestCase().assertCountEqual(
            player_3.enemy_food, universe.enemy_food(player_3.team.index))

        unittest.TestCase().assertCountEqual(
            player_0.team_food, universe.team_food(player_0.team.index))
        unittest.TestCase().assertCountEqual(
            player_1.team_food, universe.team_food(player_1.team.index))
        unittest.TestCase().assertCountEqual(
            player_2.team_food, universe.team_food(player_2.team.index))
        unittest.TestCase().assertCountEqual(
            player_3.team_food, universe.team_food(player_3.team.index))

        assert {(0, 1): (1, 2), (0, 0): (1, 1)} == \
                player_0.legal_directions
        assert {(0, 1): (15, 3), (0, -1): (15, 1), (0, 0): (15, 2),
                          (1, 0): (16, 2)} == \
                player_1.legal_directions
        assert {(0, 1): (1, 3), (0, -1): (1, 1), (0, 0): (1, 2)} == \
                player_2.legal_directions
        assert {(0, -1): (15, 2), (0, 0): (15, 3)} == \
                player_3.legal_directions

        assert player_1.current_state["round_index"] == None
        assert player_1.current_state["bot_id"] == None

        game_master.play_round()
        universe = datamodel.CTFUniverse._from_json_dict(
            game_master.game_state)

        assert player_1.current_pos == (15, 2)
        assert player_1.previous_pos == (15, 2)
        assert player_1.initial_pos == (15, 2)
        assert player_1.current_state["round_index"] == 0
        assert player_1.current_state["bot_id"] == 1
        assert universe.bots[1].current_pos == (15, 1)
        assert universe.bots[1].initial_pos == (15, 2)
        self.assertUniversesEqual(player_1.current_uni,
                                  player_1.universe_states[-1])

        game_master.play_round()
        universe = datamodel.CTFUniverse._from_json_dict(
            game_master.game_state)

        assert player_1.current_pos == (15, 1)
        assert player_1.previous_pos == (15, 2)
        assert player_1.initial_pos == (15, 2)
        assert player_1.current_state["round_index"] == 1
        assert player_1.current_state["bot_id"] == 1
        assert universe.bots[1].current_pos == (14, 1)
        assert universe.bots[1].initial_pos == (15, 2)
        self.assertUniversesNotEqual(player_1.current_uni,
                                     player_1.universe_states[-2])
示例#4
0
    def test008_UploadDocs(self):
        # загружаем документы

        time.sleep(0.5)
        wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, "//*[text()[contains(.,'Загрузить с телефона')]]")))
        ####
        try:
            t = driver.find_element_by_xpath(
                "//A[@class='FormAttachmentsTab__iconPrint']").get_attribute(
                    'href')
            filereq = requests.get(t, stream=True, verify=False)
            with open(r"/docs/Litvin//" + 'согласие_6шаг' + ".pdf",
                      "wb") as receive:
                shutil.copyfileobj(filereq.raw, receive)
            del filereq
            print("Документы Индивидуальные условия загружены")
        except:
            print("Документы Индивидуальные условия не обнаружены")
        driver.find_element_by_xpath("(//INPUT[@type='file'])[1]").send_keys(
            "/docs/Litvin/passportLi.pdf")  # passportIv.pdf PassFor6Step.pdf
        print("Загружен скан паспорта")
        # загружаем скан согласия на обработку персональных данных
        driver.find_element_by_xpath("(//INPUT[@type='file'])[3]").send_keys(
            r'/docs/Litvin/согласие_6шаг.pdf')
        print("Загружено согласие на обработку персональных данных")
        # загружаем ПТС
        driver.find_element_by_xpath("(//INPUT[@type='file'])[4]").send_keys(
            r'/docs/Litvin/ПТС_NissanJukeI.jpg')
        print("Загружен ПТС")
        driver.find_element_by_xpath("(//INPUT[@type='file'])[4]").send_keys(
            r'/docs/Litvin/ПТС_NissanJukeI.jpg')
        print("Загружен ПТС")
        # загружаем водительское удостоверение
        driver.find_element_by_xpath("(//INPUT[@type='file'])[2]").send_keys(
            r'/docs/Litvin/Dl2_Lit.jpg')
        print("Загружено ВУ")
        wait.until(
            EC.invisibility_of_element_located(
                (By.XPATH, "//DIV[@class='FormAttachmentsTab__sending']")))
        try:
            driver.find_element_by_css_selector(
                'div.FormRequestFile__name.-error')
            print('ОШИБКА ЗАГРУЗКИ ФОТО!')
            self.fail(unittest.TestCase(driver.close()))
        except:
            print("Ошибки загрузки фото не обнаружено")
        print('Извлекаем номер заявки')
        draw = driver.find_element_by_xpath(
            "//*[text()[contains(.,'Заявка №')]]").text
        global num
        num = draw[8:13]
        # отправляем заявку в банк
        driver.find_element_by_tag_name('body').send_keys(Keys.PAGE_DOWN)
        time.sleep(0.5)
        driver.find_element_by_tag_name('body').send_keys(Keys.PAGE_DOWN)
        time.sleep(0.5)
        driver.find_element_by_xpath(
            "//DIV[@class='FmButtonNext__wrap'][text()='Отправить заявку в банк']"
        ).click()
 def test_wrong_type(self):
     with self.assertRaises(TypeError):
         obj = unittest.TestCase()
         to_json(obj)
示例#6
0
 def verify_registration_form(self):
     tc = unittest.TestCase('__init__')
     registration_link = wait(self.driver, 5).until(
         EC.presence_of_element_located(self.link_registration_form))
     tc.assertEqual(registration_link.text, 'registration form')
示例#7
0
from django.utils import timezone

from ddionrails.data.models import Variable
from ddionrails.workspace.models import Basket, BasketVariable, Script
from ddionrails.workspace.resources import (
    BasketResource,
    BasketVariableExportResource,
    BasketVariableImportResource,
    ScriptExportResource,
    ScriptImportResource,
    UserResource,
)

pytestmark = [pytest.mark.django_db]  # pylint: disable=invalid-name

TEST_CASE = unittest.TestCase()


class TestUserResource:
    def test_export(self, user):
        dataset = UserResource().export()
        TEST_CASE.assertEqual(user.username, dataset["username"][0])
        TEST_CASE.assertEqual(user.email, dataset["email"][0])
        TEST_CASE.assertEqual(user.password, dataset["password"][0])

    def test_import(self):
        TEST_CASE.assertEqual(0, User.objects.count())
        now = timezone.now()
        username = "******"
        email = "*****@*****.**"
        password = "******"  # nosec
示例#8
0
        yield


@passive
def source_generator(source, rand_threshold=100):
    prng = random.Random(42)
    while True:
        if (yield source.ready) & (yield source.valid):
            source_y.append((yield source.y))
            source_cb.append((yield source.cb))
            source_cr.append((yield source.cr))
        ready = (prng.randrange(100) < rand_threshold)
        yield source.ready.eq(ready)
        yield


if __name__ == "__main__":
    tb = YCbCr422to444()
    generators = {
        "sys": [source_generator(tb.source),
                sink_generator(tb.sink)]
    }
    clocks = {"sys": 10}

    run_simulation(tb, generators, clocks, vcd_name="sim.vcd")

    testcase = unittest.TestCase()
    testcase.assertEqual(source_y, reference_y)
    testcase.assertEqual(source_cb, reference_cb)
    testcase.assertEqual(source_cr, reference_cr)
示例#9
0
def _run_tests(test_path):
    """ Run the unit tests in this file and return the results. """
    test_module = import_file_as_module(test_path)
    suite = unittest.TestLoader().loadTestsFromModule(test_module)
    test_results = unittest.TestCase().defaultTestResult()
    return suite.run(test_results)
示例#10
0
def test3():
    tc = unittest.TestCase()
    tc.assertEqual(integer_right_triangles(60), 2)
    tc.assertEqual(integer_right_triangles(100), 0)
    tc.assertEqual(integer_right_triangles(180), 3)
示例#11
0
def test4():
    tc = unittest.TestCase()
    with captured_output() as (out, err):
        gen_pattern('@')
        tc.assertEqual(out.getvalue().strip(), '@')
    with captured_output() as (out, err):
        gen_pattern('@%')
        tc.assertEqual(out.getvalue(), """
..%..
%.@.%
..%..
""")
    with captured_output() as (out, err):
        gen_pattern('ABC')
        tc.assertEqual(
            out.getvalue().strip(), """
....C....
..C.B.C..
C.B.A.B.C
..C.B.C..
....C....
""".strip())
    with captured_output() as (out, err):
        gen_pattern('#####')
        tc.assertEqual(
            out.getvalue().strip(), """
........#........
......#.#.#......
....#.#.#.#.#....
..#.#.#.#.#.#.#..
#.#.#.#.#.#.#.#.#
..#.#.#.#.#.#.#..
....#.#.#.#.#....
......#.#.#......
........#........
""".strip())
    with captured_output() as (out, err):
        gen_pattern('abcdefghijklmnop')
        tc.assertEqual(
            out.getvalue().strip(), """
..............................p..............................
............................p.o.p............................
..........................p.o.n.o.p..........................
........................p.o.n.m.n.o.p........................
......................p.o.n.m.l.m.n.o.p......................
....................p.o.n.m.l.k.l.m.n.o.p....................
..................p.o.n.m.l.k.j.k.l.m.n.o.p..................
................p.o.n.m.l.k.j.i.j.k.l.m.n.o.p................
..............p.o.n.m.l.k.j.i.h.i.j.k.l.m.n.o.p..............
............p.o.n.m.l.k.j.i.h.g.h.i.j.k.l.m.n.o.p............
..........p.o.n.m.l.k.j.i.h.g.f.g.h.i.j.k.l.m.n.o.p..........
........p.o.n.m.l.k.j.i.h.g.f.e.f.g.h.i.j.k.l.m.n.o.p........
......p.o.n.m.l.k.j.i.h.g.f.e.d.e.f.g.h.i.j.k.l.m.n.o.p......
....p.o.n.m.l.k.j.i.h.g.f.e.d.c.d.e.f.g.h.i.j.k.l.m.n.o.p....
..p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p..
p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p
..p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p..
....p.o.n.m.l.k.j.i.h.g.f.e.d.c.d.e.f.g.h.i.j.k.l.m.n.o.p....
......p.o.n.m.l.k.j.i.h.g.f.e.d.e.f.g.h.i.j.k.l.m.n.o.p......
........p.o.n.m.l.k.j.i.h.g.f.e.f.g.h.i.j.k.l.m.n.o.p........
..........p.o.n.m.l.k.j.i.h.g.f.g.h.i.j.k.l.m.n.o.p..........
............p.o.n.m.l.k.j.i.h.g.h.i.j.k.l.m.n.o.p............
..............p.o.n.m.l.k.j.i.h.i.j.k.l.m.n.o.p..............
................p.o.n.m.l.k.j.i.j.k.l.m.n.o.p................
..................p.o.n.m.l.k.j.k.l.m.n.o.p..................
....................p.o.n.m.l.k.l.m.n.o.p....................
......................p.o.n.m.l.m.n.o.p......................
........................p.o.n.m.n.o.p........................
..........................p.o.n.o.p..........................
............................p.o.p............................
..............................p..............................
""".strip())
示例#12
0
def test2():
    tc = unittest.TestCase()
    tc.assertEqual(multiples_of_3_and_5(10), 23)
    tc.assertEqual(multiples_of_3_and_5(500), 57918)
    tc.assertEqual(multiples_of_3_and_5(1000), 233168)
示例#13
0
PERSON_INSERT_CALL = call(body=TestConstants.PERSON_DATA,
                          id=TestConstants.PERSON_METADATA_ID,
                          index=Constants.PERSON_INDEX,
                          version=0)

PERSON_DELETE_CALL = call(id=TestConstants.PERSON_METADATA_ID,
                          index=Constants.PERSON_INDEX,
                          version=2)

VEHICLE_REGISTRATION_INSERT_CALL = call(
    body=TestConstants.VEHICLE_REGISTRATION_DATA,
    id=TestConstants.VEHICLE_REGISTRATION_METADATA_ID,
    index=Constants.VEHICLE_REGISTRATION_INDEX,
    version=0)

test_case_instance = unittest.TestCase('__init__')


def test_indexing_records_for_inserts(mocker, deaggregated_stream_records):
    deaggregated_records = deaggregated_stream_records(revision_version=0)

    # Mock
    mocker.patch('src.qldb_streaming_to_es_sample.app.deaggregate_records',
                 return_value=deaggregated_records)
    mocker.patch(
        'src.qldb_streaming_to_es_sample.app.elasticsearch_client.index',
        return_value={"status": "success"})

    # Trigger
    response = app.lambda_handler({"Records": ["a dummy record"]}, "")
示例#14
0
class Test_Boost():
    def test_1_small_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            frames = analysis.get_data_frame()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_SMALL_PAD"],
                                    cache=replay_cache)

    def test_1_large_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_LARGE_PAD"],
                                    cache=replay_cache)

    def test_1_large_pad_1_small_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)
            assert (boost.num_small_boosts == 1)

        run_analysis_test_on_replay(
            test,
            get_raw_replays()["12_AND_100_BOOST_PADS_0_USED"],
            cache=replay_cache)

    def test_0_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 0)
            assert (boost.num_large_boosts == 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["0_BOOST_COLLECTED"],
            cache=replay_cache)

    def test_lots_of_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert [boost.num_small_boosts, boost.num_large_boosts] == [25, 6]

        run_analysis_test_on_replay(test,
                                    get_raw_replays()["6_BIG_25_SMALL"],
                                    cache=replay_cache)

    def test_boost_steals(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert boost.num_stolen_boosts == 2

        run_analysis_test_on_replay(test,
                                    get_raw_replays()["6_BIG_25_SMALL"],
                                    cache=replay_cache)

    def test_boost_steals_post_goal(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert [
                boost.num_small_boosts, boost.num_large_boosts,
                boost.num_stolen_boosts, boost.boost_usage
            ] == [0, 0, 0, 0]

            player = proto_game.players[1]
            boost = player.stats.boost
            assert [boost.num_large_boosts, boost.num_stolen_boosts] == [3, 3]
            assert boost.boost_usage > 0

        run_analysis_test_on_replay(
            test,
            get_raw_replays()["3_STEAL_ORANGE_0_STEAL_BLUE"],
            cache=replay_cache)

    def test_boost_used(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            case.assertAlmostEqual(boost.boost_usage, boost_value, delta=1)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_USED"] +
            get_specific_replays()["0_BOOST_USED"],
            answers=get_specific_answers()["BOOST_USED"] +
            get_specific_answers()["0_BOOST_USED"],
            cache=replay_cache)
 def f():
     # We have to use a pyunit test, otherwise we'll get deprecation
     # warnings about using iterate() in a test.
     trialRunner.run(pyunit.TestCase("id"))
 def makeTestCase(self):
     return unittest.TestCase('run')
示例#17
0
 def isNotEmptyList(cls, l):
     unittest.TestCase().assertIsInstance(l, list)
     unittest.TestCase().assertTrue(l)
示例#18
0
from PageObject.execute import Drag_line
from Common.function import *
from selenium import webdriver
import unittest

class logingTest(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.driver = webdriver.Chrome(executable_path='D:\chromedriver_win32 (1)\chromedriver.exe')
        self.driver.get(config_url())

    def test1(self):
        search = Drag_line(self.driver)
        search.Unlock()

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

if __name__ == "__main__":
    suiteTest = unittest.TestCase()
    suiteTest.addTest(logingTest('test1'))
示例#19
0
 def __init__(self):
     super(LastInfoCallback, self).__init__()
     self.tc = unittest.TestCase()
     self.step = 0
示例#20
0
import numpy as np

from sklearn.base import (ClassifierMixin, RegressorMixin, TransformerMixin,
                          ClusterMixin)
from sklearn.cluster import DBSCAN

__all__ = [
    "assert_equal", "assert_not_equal", "assert_raises",
    "assert_raises_regexp", "raises", "with_setup", "assert_true",
    "assert_false", "assert_almost_equal", "assert_array_equal",
    "assert_array_almost_equal", "assert_array_less", "assert_less",
    "assert_less_equal", "assert_greater", "assert_greater_equal",
    "assert_approx_equal", "SkipTest"
]

_dummy = unittest.TestCase('__init__')
assert_equal = _dummy.assertEqual
assert_not_equal = _dummy.assertNotEqual
assert_true = _dummy.assertTrue
assert_false = _dummy.assertFalse
assert_raises = _dummy.assertRaises

try:
    SkipTest = unittest.case.SkipTest
except AttributeError:
    # Python <= 2.6, we stil need nose here
    from nose import SkipTest

try:
    assert_dict_equal = _dummy.assertDictEqual
    assert_in = _dummy.assertIn
示例#21
0
def unittest():
    tc = ut.TestCase('__init__')
    tc.longMessage = True
    return tc
示例#22
0
import unittest
import sys
import os
import logging
import LoggingConfiguration
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
tc = unittest.TestCase('__init__')


class LoggingTest(unittest.TestCase):

    def setUp(self):
        self.log = logging.getLogger(__name__)
        self.log.debug("Testing logging functionality")
    
    # check if log file exists and is not empty
    def test_log(self):
        tc.assertTrue(os.path.isfile('maze.log'), 'The file "maze.log" cannot be found!')
        tc.assertNotEqual(os.stat("maze.log").st_size, 0, 'The file "maze.log" is empty!')


# This is needed for the individual execution of this test class
if __name__ == "__main__":
    logging.config.dictConfig(LoggingConfiguration.LOGGING)
    suite = unittest.TestLoader().loadTestsFromTestCase(LoggingTest)
    unittest.TextTestRunner(verbosity=2).run(suite)
示例#23
0
 def __init__(self):
     self.__asserter = unittest.TestCase('__init__')
示例#24
0
 def __init__(self, project):
     self.project = project
     self.tc = unittest.TestCase('__init__')
     self.tc.maxDiff = None
示例#25
0
def self():
    return unittest.TestCase()
示例#26
0
 def __init__(self, pkg):
     self.pkg = pkg
     self.temp_dir = None
     self.tc = unittest.TestCase('__init__')
     self.tc.maxDiff = None
示例#27
0
    host = ReadConfig().get_http('url')

    def activation_code(self, code):
        data = {"code": code}
        url = self.host + 'owner/user/' + str(
            Util().get_user_id()) + '/activation_code'
        LOG.info("请求url:%s" % url)
        req = requests.post(url=url, json=data, headers=Util().get_token())
        return req.json()

    def test_activation_code_correct_parameters(self):
        u"""正确参数"""
        LOG.info('------登录成功用例:start!---------')
        result = self.activation_code("3CFL6VEWDLRFQYTE")
        LOG.info('获取测试结果:%s' % result)
        self.assertOkResult(result)
        LOG.info('------pass!---------')

    def test_activation_code_error_parameters(self):
        u"""正确参数"""
        LOG.info('------登录成功用例:start!---------')
        result = self.activation_code(" ")
        LOG.info('获取测试结果:%s' % result)
        self.assertErrorResult(result, const.ErrDatabase)
        LOG.info('------pass!---------')


if __name__ == '__main__':
    unittest.TestCase()
示例#28
0
 def __init__(self, zip_file_path):
     self.zip_file_path = zip_file_path
     self.temp_dir = None
     self.tc = unittest.TestCase('__init__')
示例#29
0
 def _make_test_with_id(test_id):
     test = unittest.TestCase()
     test.id = lambda: test_id
     return test
示例#30
0
from python.math.weather import Temperature
import pytest
import unittest
assertions = unittest.TestCase('__init__')

SIGNIFICANT_PLACES = 4

knownValues = (
    (-273.15, -459.67),  # absolute zero
    (-89, -128.2),  # coldest recorded WX temp on earth's surface
    (-17.777777777, 0),  # temp of Daniel Gabriel Fahrenheit's ice/salt mixture
    (0, 32),  # H20 freezes
    (15, 59),  # average earth WX temp
    (36.8, 98.24),  # average body temperature
    (58, 136.4),  # warmest recorded WX temp on earth's surface
    (100, 212),  # H20 boils
    (5535, 9995))  # average WX temp on the sun's surface


def test_to_fahrenheit_known_values():
    """converting to Fahrenheit should give known result with known input"""
    for tempC, tempF in knownValues:
        result = Temperature(celsius=tempC).fahrenheit()
        assertions.assertAlmostEqual(tempF, result, SIGNIFICANT_PLACES)


def test_to_celsius_known_values():
    """converting from Fahrenheit should give known back our known inputs"""
    for tempC, tempF in knownValues:
        result = Temperature(fahrenheit=tempF).celsius()
        assertions.assertAlmostEqual(tempC, result, SIGNIFICANT_PLACES)