コード例 #1
0
ファイル: executable_file.py プロジェクト: emilkarlen/exactly
 def check_both_single_and_multiple_line_source(
         self,
         put: unittest.TestCase,
         first_source_line_instruction_argument_source_template: str,
         act_phase_source_lines: list,
         expected_cmd_and_args: ValueAssertion,
         hds_contents: home_populators.HomePopulator = home_populators.empty()):
     instruction_argument_source = first_source_line_instruction_argument_source_template.format_map(
         self.format_map_for_template_string)
     for source, source_assertion in equivalent_source_variants_with_assertion(put, instruction_argument_source):
         # ARRANGE #
         os_process_executor = AtcOsProcessExecutorThatRecordsArguments()
         arrangement = Arrangement(source,
                                   act_phase_source_lines,
                                   atc_os_process_executor=os_process_executor,
                                   hds_contents=hds_contents)
         expectation = Expectation(source_after_parse=source_assertion)
         # ACT #
         check(put, arrangement, expectation)
         # ASSERT #
         put.assertFalse(os_process_executor.command.shell,
                         'Command should not indicate shell execution')
         actual_cmd_and_args = os_process_executor.command.args
         put.assertIsInstance(actual_cmd_and_args, list,
                              'Arguments of command to execute should be a list of arguments')
         put.assertTrue(len(actual_cmd_and_args) > 0,
                        'List of arguments is expected to contain at least the file|interpreter argument')
         expected_cmd_and_args.apply_with_message(put, actual_cmd_and_args, 'actual_cmd_and_args')
コード例 #2
0
def test_queue_implementation_2():
    tc = TestCase()

    q = Queue(10)

    for i in range(6):
        q.enqueue(i)

    tc.assertEqual(q.data.count(None), 4)

    for i in range(5):
        q.dequeue()

    tc.assertFalse(q.empty())
    tc.assertEqual(q.data.count(None), 9)
    tc.assertEqual(q.head, q.tail)
    tc.assertEqual(q.head, 5)

    for i in range(9):
        q.enqueue(i)

    with tc.assertRaises(RuntimeError):
        q.enqueue(10)

    for x, y in zip(q, [5] + list(range(9))):
        tc.assertEqual(x, y)

    tc.assertEqual(q.dequeue(), 5)
    for i in range(9):
        tc.assertEqual(q.dequeue(), i)

    tc.assertTrue(q.empty())
コード例 #3
0
def _check(
    put: unittest.TestCase,
    expected_space_root_dir: pathlib.Path,
    actual_storage: sut.TmpFileStorage,
):
    storage_root_dir__may_not_exist = actual_storage.root_dir__may_not_exist
    put.assertEqual(expected_space_root_dir, storage_root_dir__may_not_exist)

    put.assertFalse(
        storage_root_dir__may_not_exist.exists(),
        'space root dir should not exist directly after storage creation')
    storage_dir__existing = actual_storage.root_dir__existing
    put.assertTrue(storage_dir__existing.is_dir(),
                   'space root dir should be created when accessed')
    put.assertEqual(
        storage_root_dir__may_not_exist, storage_dir__existing,
        'Dirs should be the same - regardless of accessed via _may_not_exist or __existing'
    )
    fst_path = actual_storage.paths_access.new_path()
    snd_path = actual_storage.paths_access.new_path()
    storage_root_dir = storage_root_dir__may_not_exist
    put.assertEqual(storage_root_dir / _expected_path_in_space(1), fst_path,
                    '1st path in space')
    put.assertEqual(storage_root_dir / _expected_path_in_space(2), snd_path,
                    '2nd path in space')
コード例 #4
0
 def test_hideHud(self):
     self.game.showHud('playerHud')
     TestCase.assertTrue(self,
                         self.game.tilemap.layers['playerHud'].visible)
     self.game.hideHud('playerHud')
     TestCase.assertFalse(self,
                          self.game.tilemap.layers['playerHud'].visible)
コード例 #5
0
 def _apply(self,
            put: unittest.TestCase,
            value,
            message_builder: asrt.MessageBuilder):
     put.assertIsInstance(value, spe.ResultAndStderr)
     put.assertFalse(value.result.is_success,
                     message_builder.apply('Result is expected to indicate failure'))
コード例 #6
0
    def test_transaction0(self):
        trans0 = self.res.listTransactions[0]
        TestCase.assertFalse(self, trans0.actions[0].type)  # out
        TestCase.assertEqual(self, trans0.actions[0].channel, 0)
        TestCase.assertEqual(self, trans0.actions[0].label,
                             EGreekCharacters.ALPHA.__str__ + "0out")
        TestCase.assertEqual(self, trans0.actions[0].rootTerm.name, "concat")
        TestCase.assertEqual(self,
                             trans0.actions[0].rootTerm.arguments[0].name,
                             "pub")
        TestCase.assertEqual(self,
                             trans0.actions[0].rootTerm.arguments[1].name,
                             "pub")

        ska = self.res.getVarInlist("ska")
        skb = self.res.getVarInlist("skb")

        TestCase.assertEqual(
            self, trans0.actions[0].rootTerm.arguments[0].arguments[0], ska)
        TestCase.assertEqual(
            self, trans0.actions[0].rootTerm.arguments[1].arguments[0], skb)

        kaenca = self.res.getTypeInlist("kaenca")
        kaencb = self.res.getTypeInlist("kaencb")

        TestCase.assertEqual(self, ska.type, kaenca)
        TestCase.assertEqual(self, skb.type, kaencb)
コード例 #7
0
ファイル: value_assertion.py プロジェクト: emilkarlen/exactly
 def _apply(self,
            put: unittest.TestCase,
            value: T,
            message_builder: MessageBuilder = MessageBuilder()):
     msg = message_builder.apply(self.message)
     if self.expected:
         put.assertTrue(value, msg)
     else:
         put.assertFalse(value, msg)
コード例 #8
0
ファイル: value_assertion.py プロジェクト: emilkarlen/exactly
 def _apply(self,
            put: unittest.TestCase,
            value: T,
            message_builder: MessageBuilder = MessageBuilder()):
     msg = message_builder.apply(self.message)
     if self.expected:
         put.assertTrue(value, msg)
     else:
         put.assertFalse(value, msg)
コード例 #9
0
ファイル: lab09.py プロジェクト: IITTeaching/cs331-s21-wbuerk
def test_lookup():
    for i in range(0, 10):
        vals = [random.randint(0, 100) for i in range(0, 100)]
        vals = list(set(vals))
        random.shuffle(vals)
        t = check_inserted(vals)
        tc = TestCase()
        for v in vals:
            tc.assertTrue(v in t)
        for v in [random.randint(101, 1000) for i in range(0, 100)]:
            tc.assertFalse(v in t)
コード例 #10
0
def _test_remove_edges(test: unittest.TestCase, cls: Type[Algorithm]):
    g = nx.gnp_random_graph(20, 0.3, seed=42)
    removal_order = np.random.RandomState(seed=42).permutation(g.edges)
    algo = cls(g)

    test.assertTrue(algo.is_valid_mis())

    for e in removal_order:
        algo.remove_edge(*e)
        test.assertFalse(e in g.edges)
        test.assertTrue(algo.is_valid_mis())
コード例 #11
0
def tmp_dir_is_correct_for_each_instruction(
        recordings: Dict[PhaseEnum,
                         List[pathlib.Path]], num_instructions_per_phase: int,
        put: unittest.TestCase, actual: Result):
    sds = actual.sds

    def dirs_for_validation(phase: Phase) -> List[pathlib.Path]:
        file_space_factory = PhaseTmpFileSpaceFactory(sds.internal_tmp_dir)
        return [
            file_space_factory.instruction__validation(
                phase, n).root_dir__may_not_exist
            for n in range(1, num_instructions_per_phase + 1)
        ]

    def dirs_for_main(phase: Phase) -> List[pathlib.Path]:
        file_space_factory = PhaseTmpFileSpaceFactory(sds.internal_tmp_dir)
        return [
            file_space_factory.instruction__main(phase,
                                                 n).root_dir__may_not_exist
            for n in range(1, num_instructions_per_phase + 1)
        ]

    def dirs_for_act() -> List[pathlib.Path]:
        space_factory__v = PhaseTmpFileSpaceFactory(sds.internal_tmp_dir)
        space_factory__m = PhaseTmpFileSpaceFactory(sds.internal_tmp_dir)

        return [
            space_factory__v.for_phase__validation(
                phase_identifier.ACT).root_dir__may_not_exist,
            space_factory__m.for_phase__main(
                phase_identifier.ACT).root_dir__may_not_exist,
            space_factory__m.for_phase__main(
                phase_identifier.ACT).root_dir__may_not_exist,
        ]

    put.assertFalse(actual.partial_result.is_failure)

    expected = {
        PhaseEnum.SETUP:
        dirs_for_main(phase_identifier.SETUP) +
        dirs_for_validation(phase_identifier.SETUP),
        PhaseEnum.ACT:
        dirs_for_act(),
        PhaseEnum.BEFORE_ASSERT:
        dirs_for_validation(phase_identifier.BEFORE_ASSERT) +
        dirs_for_main(phase_identifier.BEFORE_ASSERT),
        PhaseEnum.ASSERT:
        dirs_for_validation(phase_identifier.ASSERT) +
        dirs_for_main(phase_identifier.ASSERT),
        PhaseEnum.CLEANUP:
        dirs_for_main(phase_identifier.CLEANUP),
    }
    put.assertDictEqual(expected, recordings, 'Tmp directory per phase')
コード例 #12
0
    def _apply(self,
               put: unittest.TestCase,
               actual: Pattern,
               message_builder: MessageBuilder):
        put.assertEqual(self.pattern_string,
                        actual.pattern,
                        'regex pattern string')
        for matching_string in self.matching_string_list:
            put.assertTrue(bool(actual.search(matching_string)),
                           'reg-ex should match "{}"'.format(matching_string))

        put.assertFalse(bool(actual.search(self.non_matching_string)),
                        'reg-ex should not match "{}"'.format(self.non_matching_string))
コード例 #13
0
    def _apply(self,
               put: unittest.TestCase,
               value,
               message_builder: asrt.MessageBuilder):
        put.assertIsInstance(value, SymbolStringFragmentResolver)
        assert isinstance(value, SymbolStringFragmentResolver)  # Type info for IDE

        put.assertFalse(value.is_string_constant,
                        'is_string_constant')

        put.assertEqual(self.expected.symbol_name,
                        value.symbol_name,
                        'symbol_name')
コード例 #14
0
ファイル: parse_regex.py プロジェクト: emilkarlen/exactly
    def _apply(self,
               put: unittest.TestCase,
               actual: Pattern,
               message_builder: MessageBuilder):
        put.assertEqual(self.pattern_string,
                        actual.pattern,
                        'regex pattern string')
        for matching_string in self.matching_string_list:
            put.assertTrue(bool(actual.search(matching_string)),
                           'reg-ex should match "{}"'.format(matching_string))

        put.assertFalse(bool(actual.search(self.non_matching_string)),
                        'reg-ex should not match "{}"'.format(self.non_matching_string))
コード例 #15
0
def _assert_source_is_not_at_eof_and_has_current_whole_line(put: unittest.TestCase,
                                                            source: ParseSource,
                                                            expected_current_line: str):
    put.assertTrue(source.has_current_line,
                   'There should be remaining lines in the source')
    put.assertFalse(source.is_at_eof,
                    'There should be remaining source')
    put.assertEqual(expected_current_line,
                    source.current_line_text,
                    'Should should have given current line')
    put.assertEqual(expected_current_line,
                    source.remaining_part_of_current_line,
                    'Current line should be identical to remaining-part-of-current-line')
コード例 #16
0
ファイル: sdv_assertions.py プロジェクト: emilkarlen/exactly
    def _apply(self,
               put: unittest.TestCase,
               value,
               message_builder: asrt.MessageBuilder):
        put.assertIsInstance(value, SymbolStringFragmentSdv)
        assert isinstance(value, SymbolStringFragmentSdv)  # Type info for IDE

        put.assertFalse(value.is_string_constant,
                        message_builder.apply('is_string_constant'))

        put.assertEqual(self.expected.symbol_name,
                        value.symbol_name,
                        message_builder.apply('symbol_name'))
コード例 #17
0
def _assert_source_is_not_at_eof_and_has_current_whole_line(put: unittest.TestCase,
                                                            source: ParseSource,
                                                            expected_current_line: str):
    put.assertTrue(source.has_current_line,
                   'There should be remaining lines in the source')
    put.assertFalse(source.is_at_eof,
                    'There should be remaining source')
    put.assertEqual(expected_current_line,
                    source.current_line_text,
                    'Should should have given current line')
    put.assertEqual(expected_current_line,
                    source.remaining_part_of_current_line,
                    'Current line should be identical to remaining-part-of-current-line')
コード例 #18
0
def _test_remove_nodes(test: unittest.TestCase, cls: Type[Algorithm]):
    g = nx.gnp_random_graph(20, 0.3, seed=42)
    removal_order = np.random.RandomState(seed=42).permutation(g.nodes)
    algo = cls(g)

    test.assertTrue(algo.is_valid_mis())

    for n in removal_order:
        algo.remove_node(n)
        # algo.sanity_check()
        test.assertFalse(n in g.nodes)
        valid = algo.is_valid_mis()
        test.assertTrue(valid)
コード例 #19
0
def log_dir_is_correct_for_each_phase(recordings: dict,
                                      put: unittest.TestCase,
                                      actual: Result):
    put.assertFalse(actual.partial_result.is_failure)
    sds = actual.sds
    expected = {
        PhaseEnum.SETUP: sds_log_phase_dir(sds, phase_identifier.SETUP.identifier),
        PhaseEnum.BEFORE_ASSERT: sds_log_phase_dir(sds, phase_identifier.BEFORE_ASSERT.identifier),
        PhaseEnum.ASSERT: sds_log_phase_dir(sds, phase_identifier.ASSERT.identifier),
        PhaseEnum.CLEANUP: sds_log_phase_dir(sds, phase_identifier.CLEANUP.identifier),
    }
    put.assertDictEqual(expected,
                        recordings,
                        'Log directory per phase')
コード例 #20
0
def assert_equal_failure_details(unit_tc: unittest.TestCase,
                                 expected: FailureDetails,
                                 actual: FailureDetails):
    if expected.is_only_failure_message:
        unit_tc.assertTrue(actual.is_only_failure_message,
                           'An error message is expected')
        unit_tc.assertEqual(expected.failure_message,
                            actual.failure_message,
                            'The failure message should be the expected')
    else:
        unit_tc.assertFalse(actual.is_only_failure_message,
                            'An exception is expected')
        unit_tc.assertEqual(expected.exception,
                            actual.exception,
                            'The exception should be the expected')
コード例 #21
0
    def make_assertions(cls, test: unittest.TestCase,
                        retriever: crosswalk.CrosswalkRetriever,
                        expected_mapping: typing.List[typing.Dict[str, str]]):
        data = retriever.retrieve()
        print("Data Retrieved")

        test.assertEqual(len(data), len(expected_mapping))

        for mapping in expected_mapping:
            search_results = data[(data[retriever.prediction_field_name] ==
                                   mapping["predicted_location"])
                                  & (data[retriever.observation_field_name] ==
                                     mapping["observed_location"])]

            test.assertFalse(search_results.empty)
コード例 #22
0
    def test_publicDeclarations(self):
        a = self.res.getVarInlist("a")
        TestCase.assertNotEqual(self, a, None)
        TestCase.assertNotEqual(self, self.res.getVarInlist("b"), None)
        TestCase.assertNotEqual(self, self.res.getVarInlist("c"), None)

        typea = self.res.getTypeInlist("typea")
        TestCase.assertNotEqual(self, typea, None)
        TestCase.assertNotEqual(self, self.res.getTypeInlist("typeb"), None)
        TestCase.assertNotEqual(self, self.res.getTypeInlist("typec"), None)

        TestCase.assertFalse(self, a.onTheFly)
        TestCase.assertEqual(self, a.type, typea)
        TestCase.assertTrue(self, typea.public)
        TestCase.assertFalse(self, typea.honest)
コード例 #23
0
def test_check_delimiters_4():
    tc = TestCase()
    tc.assertFalse(check_delimiters('('))
    tc.assertFalse(check_delimiters('['))
    tc.assertFalse(check_delimiters('{'))
    tc.assertFalse(check_delimiters('<'))
    tc.assertFalse(check_delimiters(')'))
    tc.assertFalse(check_delimiters(']'))
    tc.assertFalse(check_delimiters('}'))
    tc.assertFalse(check_delimiters('>'))
コード例 #24
0
def test_check_delimiters_4():
    tc = TestCase()
    tc.assertFalse(check_delimiters("("))
    tc.assertFalse(check_delimiters("["))
    tc.assertFalse(check_delimiters("{"))
    tc.assertFalse(check_delimiters("<"))
    tc.assertFalse(check_delimiters(")"))
    tc.assertFalse(check_delimiters("]"))
    tc.assertFalse(check_delimiters("}"))
    tc.assertFalse(check_delimiters(">"))
コード例 #25
0
 def _setup_repo(test_case: unittest.TestCase) -> str:
     test_case.assertFalse(os.path.isdir(FileHelper.git_dir))
     test_case.assertFalse(os.path.isdir(FileHelper.git_dir + "/.git"))
     test_case.assertFalse(os.path.isfile(FileHelper.pom_path_in_git))
     test_case.assertFalse("/" in FileHelper.git_dir
                           or "." in FileHelper.git_dir)
     cwd1 = subprocess.run(['pwd'], check=True,
                           stdout=subprocess.PIPE).stdout.decode('utf-8')
     test_case.assertTrue(str(cwd1))
     return cwd1
コード例 #26
0
def _expect_string(put: unittest.TestCase,
                   source: ParseSource,
                   expectation: ExpectedString):
    # ACT #
    actual = sut.parse_from_parse_source(source)
    # ASSERT #
    put.assertIs(string_or_file.SourceType.STRING,
                 actual.source_type,
                 'source type')
    put.assertFalse(actual.is_file_ref,
                    'is_file_ref')
    assertion_on_here_doc = asrt_string.matches_primitive_string(asrt.equals(expectation.resolved_str),
                                                                 expectation.common.symbol_references,
                                                                 expectation.common.symbol_table)
    assertion_on_here_doc.apply_with_message(put, actual.string_resolver,
                                             'string_resolver')
    _expect_common(put, source, actual,
                   expectation.common)
コード例 #27
0
def _expect_here_doc(put: unittest.TestCase,
                     source: ParseSource,
                     expectation: ExpectedHereDoc):
    # ACT #
    actual = sut.parse_from_parse_source(source)
    # ASSERT #
    put.assertIs(string_or_file.SourceType.HERE_DOC,
                 actual.source_type,
                 'source type')
    put.assertFalse(actual.is_file_ref,
                    'is_file_ref')
    assertion_on_here_doc = asrt_hd.matches_resolved_value(expectation.resolved_here_doc_lines,
                                                           expectation.common.symbol_references,
                                                           expectation.common.symbol_table)
    assertion_on_here_doc.apply_with_message(put, actual.string_resolver,
                                             'here_document')
    _expect_common(put, source, actual,
                   expectation.common)
コード例 #28
0
    def test_variable_render_limit(self, variables):
        """LabelTable should not be rendered for more than 100 variables.

        The creation of the HTML of the LabelTable is to time consuming for large
        numbers of related variables.
        """

        # To use unittest assertions with this pytest setup.
        # Class should be refactored to inherit TestCase if time can be allocated.
        test = TestCase()

        for _ in range(0, 100):
            variables.append(variables[0])
        label_table = LabelTable(variables)
        # Do not render a LabelTable if variable count exceeds the limit.
        test.assertFalse(label_table.render_table)
        # Throw away all variables for the LabelTable if their number exceeds
        # the limit.
        test.assertEqual(list(), label_table.variables)
コード例 #29
0
    def test_label_render_limit(self, variables):
        """LabelTable should not be rendered for variable with more than 100 labels.

        The creation of the HTML of the LabelTable is to time consuming for large
        numbers of labels.
        """

        categories = list()
        for number in range(0, 101):
            categories.append({"label": uuid4(), "value": number})

        # To use unittest assertions with this pytest setup.
        # Class should be refactored to inherit TestCase if time can be allocated.
        test = TestCase()

        with patch.object(Variable, "category_list", categories):
            label_table = LabelTable(variables)
            test.assertFalse(label_table.render_table)
            test.assertEqual("", label_table.to_html())
コード例 #30
0
ファイル: test.py プロジェクト: johnchinjew/hangmen
def check_session_state(test: unittest.TestCase,
                        state: dict,
                        sid: str = None,
                        players: list = [],
                        turnOrderContains: list = None,
                        turnOrder: list = None,
                        guessedLetters: str = '',
                        isLobby: bool = True):

    # First check consistency of input
    assert (not ((turnOrderContains is not None) and
                 ((turnOrder is not None))))
    if isLobby:
        if turnOrderContains is not None:
            assert (len(turnOrderContains) == 0)
        if turnOrder is not None:
            assert (len(turnOrder) == 0)
        assert (len(guessedLetters) == 0)

    # Run equality check on state using input
    for attr in ['id', 'players', 'turnOrder', 'alphabet', 'isLobby']:
        test.assertIn(attr, state)
    if sid is not None:
        test.assertEqual(state['id'], sid)
    test.assertEqual(len(state['players']), len(players))
    for pid in players:
        test.assertIn(pid, state['players'])
    # Cannot check ACTUAL turn order (since it is shuffled)
    # only check if they both contain same elements
    if turnOrderContains is not None:
        for pid in turnOrderContains:
            test.assertIn(pid, state['turnOrder'])
    if turnOrder is not None:
        test.assertEqual(state['turnOrder'], turnOrder)
    for c in 'abcdefghjiklmnopqrstuvwxyz':
        test.assertIn(c, state['alphabet']['letters'])
        if c in guessedLetters:
            test.assertTrue(state['alphabet']['letters'][c])
        else:
            test.assertFalse(state['alphabet']['letters'][c])
    test.assertEqual(state['isLobby'], isLobby)
コード例 #31
0
 def test_VerifyDatabaseAlbums(self):
     """Tests for errors in database entries generated by scraper.py. Test fails if entry in albums table is missing
     description or image link. The test will also fail if description contains } or { characters, which indicate
     scraper.py improperly retrieved data."""
     data = DataSource.DataSource()
     albums = data.getAllAlbumsFromDatabase()
     for album in albums:
         error_description = "Missing album description for %s" % (
             album.getAlbumName())
         error_description2 = "Invalid album description for %s" % (
             album.getAlbumName())
         error_image = "Missing album image for %s" % (album.getAlbumName())
         TestCase.assertTrue(self,
                             len(album.getAlbumDescription()) > 0,
                             error_description)
         TestCase.assertTrue(self,
                             len(album.getAlbumImage()) > 0, error_image)
         TestCase.assertFalse(self, '}' in album.getAlbumDescription(),
                              error_description2)
         TestCase.assertFalse(self, '{' in album.getAlbumDescription(),
                              error_description2)
コード例 #32
0
def test_case_4():
    test_log("testing predicates")
    tc = TestCase()
    lst = ArrayList()
    lst2 = ArrayList()

    lst.data = ConstrainedList.create([])
    lst.len = len(lst.data)
    lst2.data = ConstrainedList.create([1, 2, 3])
    lst2.len = len(lst2.data)
    tc.assertNotEqual(lst, lst2)

    lst.data = ConstrainedList.create([1, 2, 3])
    lst.len = len(lst.data)
    tc.assertEqual(lst, lst2)

    lst.data = ConstrainedList.create([])
    lst.len = len(lst.data)
    tc.assertFalse(1 in lst)
    tc.assertFalse(None in lst)

    lst.data = ConstrainedList.create(range(100))
    lst.len = len(lst.data)
    tc.assertFalse(100 in lst)
    tc.assertTrue(50 in lst)
    suc()
コード例 #33
0
ファイル: test_objects.py プロジェクト: jakejack13/gachapy
def test_item_change_rarity(test: unittest.TestCase, item: Item, rarity: float):
    """Asserts that the changed rarity of the item is equal to the inputted
    rarity or if the output is False if the rarity is not valid

    Parameters
    ----------
    test : unittest.TestCase
        the test case to run the test on
    item : Item
        the item to change the rarity of
    rarity : float
        the rarity to change to
    """
    old_rarity = item.rarity
    result = item.change_rarity(rarity)
    new_rarity = item.rarity
    item.rarity = old_rarity
    if rarity <= 0:
        test.assertFalse(result)
    else:
        test.assertTrue(result)
        test.assertEqual(new_rarity, rarity)
コード例 #34
0
    def test_onTheFlyDeclarations(self):
        xb = self.res.getVarInlist("xb")
        xa0 = self.res.getVarInlist("xa0")
        TestCase.assertNotEqual(self, xb, None)
        TestCase.assertNotEqual(self, xa0, None)

        noncem = self.res.getTypeInlist("noncem")
        noncek = self.res.getTypeInlist("noncek")
        TestCase.assertNotEqual(self, noncem, None)
        TestCase.assertNotEqual(self, noncek, None)

        TestCase.assertTrue(self, xb.onTheFly)
        TestCase.assertTrue(self, xa0.onTheFly)
        TestCase.assertEqual(self, xb.type, noncek)
        TestCase.assertEqual(self, xa0.type, noncem)

        TestCase.assertFalse(self, noncem.public)
        TestCase.assertFalse(self, noncek.public)
        TestCase.assertFalse(self, noncem.honest)
        TestCase.assertFalse(self, noncek.honest)
コード例 #35
0
def test_predicates():
    say_test("test_predicates")
    tc = TestCase()
    lst = LinkedList()
    lst2 = LinkedList()

    tc.assertEqual(lst, lst2)

    lst2.append(100)
    tc.assertNotEqual(lst, lst2)
    lst.append(100)
    tc.assertEqual(lst, lst2)

    tc.assertFalse(1 in lst)
    tc.assertFalse(None in lst)

    lst = LinkedList()
    for i in range(100):
        lst.append(i)
    tc.assertFalse(100 in lst)
    tc.assertTrue(50 in lst)
コード例 #36
0
ファイル: file_checks.py プロジェクト: emilkarlen/exactly
 def _apply(self,
            put: unittest.TestCase,
            value: pathlib.Path,
            message_builder: MessageBuilder):
     put.assertFalse(value.exists(),
                     message_builder.msg_for_sub_component('exists'))
コード例 #37
0
def test_check_delimiters_6():
    tc = TestCase()
    tc.assertFalse(check_delimiters('[ ( ] )'))
    tc.assertFalse(check_delimiters('((((((( ))))))'))
    tc.assertFalse(check_delimiters('< < > > >'))
    tc.assertFalse(check_delimiters('( [] < {} )'))
コード例 #38
0
def test_check_delimiters_5():
    tc = TestCase()
    tc.assertFalse(check_delimiters('( ]'))
    tc.assertFalse(check_delimiters('[ )'))
    tc.assertFalse(check_delimiters('{ >'))
    tc.assertFalse(check_delimiters('< )'))
コード例 #39
0
ファイル: token_stream.py プロジェクト: emilkarlen/exactly
def assert_is_not_null(put: unittest.TestCase, actual: sut.TokenStream):
    put.assertFalse(actual.is_null,
                    'is null')
    put.assertIsNot(LookAheadState.NULL,
                    actual.look_ahead_state,
                    'look ahead state')
コード例 #40
0
ファイル: q020.py プロジェクト: odys-z/hello
            if c == ' ': continue  # for string readable
            if c in ('(', '{', '['):
                stk.append(c)
            elif len(stk) > 0:
                if (stk[-1] == '(' and c == ')' or stk[-1] == '{' and c == '}'
                        or stk[-1] == '[' and c == ']'):
                    stk.pop()
                else:
                    return False
            else:
                return False
        return len(stk) == 0


if __name__ == '__main__':
    t = TestCase()
    s = Solution()

    t.assertTrue(s.isValid(''))
    t.assertTrue(s.isValid('()'))
    t.assertTrue(s.isValid('()[]{}'))
    t.assertTrue(s.isValid('()[{}]'))
    t.assertTrue(s.isValid('([{}])'))
    t.assertTrue(s.isValid('() [{}] [] [[[]]]'))
    t.assertFalse(s.isValid('(( [{}] [] [[[]]]'))
    t.assertFalse(s.isValid('(( [{}] [] [[[]]] )'))
    t.assertTrue(s.isValid('(( [{}] [] [[[]]] ))'))
    t.assertFalse(s.isValid('([{])'))
    t.assertFalse(s.isValid('([{]})'))

    print('OK!')
コード例 #41
0
ファイル: deletion_of_sds.py プロジェクト: emilkarlen/exactly
def sandbox_directory_structure_does_not_exist(put: unittest.TestCase,
                                               actual: Result):
    _common_assertions(actual, put)
    put.assertFalse(actual.partial_result.sds.root_dir.exists())
コード例 #42
0
def _assert_source_is_at_end(put: unittest.TestCase, source: ParseSource):
    put.assertFalse(source.has_current_line,
                    'There should be no remaining lines in the source')
    put.assertTrue(source.is_at_eof,
                   'There should be no remaining data in the source')
コード例 #43
0
    def test_privateDeclarations(self):
        ska = self.res.getVarInlist("ska")
        k0 = self.res.getVarInlist("k0")
        n1 = self.res.getVarInlist("n1")
        TestCase.assertNotEqual(self, ska, None)
        TestCase.assertNotEqual(self, self.res.getVarInlist("skb"), None)
        TestCase.assertNotEqual(self, self.res.getVarInlist("skc"), None)
        TestCase.assertNotEqual(self, k0, None)
        TestCase.assertNotEqual(self, n1, None)

        noncem = self.res.getTypeInlist("noncem")
        kaenca = self.res.getTypeInlist("kaenca")
        noncek = self.res.getTypeInlist("noncek")
        TestCase.assertNotEqual(self, noncem, None)
        TestCase.assertNotEqual(self, kaenca, None)
        TestCase.assertNotEqual(self, self.res.getTypeInlist("kaencb"), None)
        TestCase.assertNotEqual(self, self.res.getTypeInlist("kaencc"), None)
        TestCase.assertNotEqual(self, noncek, None)

        TestCase.assertFalse(self, k0.onTheFly)
        TestCase.assertFalse(self, n1.onTheFly)
        TestCase.assertFalse(self, ska.onTheFly)
        TestCase.assertEqual(self, ska.type, kaenca)
        TestCase.assertEqual(self, k0.type, noncek)
        TestCase.assertEqual(self, n1.type, noncem)

        TestCase.assertFalse(self, noncem.public)
        TestCase.assertFalse(self, kaenca.public)
        TestCase.assertFalse(self, noncek.public)
        TestCase.assertFalse(self, noncem.honest)
        TestCase.assertTrue(self, kaenca.honest)
        TestCase.assertFalse(self, noncek.honest)
コード例 #44
0
    def test_transaction3(self):
        trans3 = self.res.listTransactions[3]
        # action 0
        TestCase.assertFalse(self, trans3.actions[0].type)  # out
        TestCase.assertEqual(self, trans3.actions[0].channel, 3)
        TestCase.assertEqual(self, trans3.actions[0].label,
                             EGreekCharacters.DELTA.__str__ + "0out")
        TestCase.assertEqual(self, trans3.actions[0].rootTerm.name, "aenc")
        TestCase.assertEqual(self,
                             trans3.actions[0].rootTerm.arguments[0].name,
                             "sign")
        TestCase.assertEqual(self,
                             trans3.actions[0].rootTerm.arguments[1].name,
                             "pub")
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[0].name,
            "concat")

        a = self.res.getVarInlist("a")
        c = self.res.getVarInlist("c")
        k1 = self.res.getVarInlist("k1")
        ska = self.res.getVarInlist("ska")
        skc = self.res.getVarInlist("skc")

        TestCase.assertEqual(
            self,
            trans3.actions[0].rootTerm.arguments[0].arguments[0].arguments[0],
            a)
        TestCase.assertEqual(
            self,
            trans3.actions[0].rootTerm.arguments[0].arguments[0].arguments[1],
            c)
        TestCase.assertEqual(
            self,
            trans3.actions[0].rootTerm.arguments[0].arguments[0].arguments[2],
            k1)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[1], ska)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[1].arguments[0], skc)

        typea = self.res.getTypeInlist("typea")
        typec = self.res.getTypeInlist("typec")
        noncek = self.res.getTypeInlist("noncek")
        kaenca = self.res.getTypeInlist("kaenca")
        kaencc = self.res.getTypeInlist("kaencc")

        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[0].
            arguments[0].type, typea)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[0].
            arguments[1].type, typec)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[0].
            arguments[2].type, noncek)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[0].arguments[1].type,
            kaenca)
        TestCase.assertEqual(
            self, trans3.actions[0].rootTerm.arguments[1].arguments[0].type,
            kaencc)

        # action 1
        TestCase.assertTrue(self, trans3.actions[1].type)  # in
        TestCase.assertEqual(self, trans3.actions[1].channel, 3)
        TestCase.assertEqual(self, trans3.actions[1].label,
                             EGreekCharacters.DELTA.__str__ + "1in")
        TestCase.assertEqual(self, trans3.actions[1].rootTerm.name, "senc")
        xa1 = self.res.getVarInlist("xa1")

        TestCase.assertEqual(self, trans3.actions[1].rootTerm.arguments[0],
                             xa1)
        TestCase.assertEqual(self, trans3.actions[1].rootTerm.arguments[1], k1)

        noncem = self.res.getTypeInlist("noncem")
        TestCase.assertEqual(self,
                             trans3.actions[1].rootTerm.arguments[0].type,
                             noncem)
        TestCase.assertEqual(self,
                             trans3.actions[1].rootTerm.arguments[1].type,
                             noncek)