How to use the nose.tools.assert_true function in nose

To help you get started, we’ve selected a few nose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudera / hue / apps / useradmin / src / useradmin / test_ldap_deprecated.py View on Github external
# Only sync already imported
      ldap_access.CACHED_LDAP_CONN.remove_posix_user_group_for_test('posix_person', 'PosixGroup')
      import_ldap_groups(ldap_access.CACHED_LDAP_CONN, 'PosixGroup', import_members=False, import_members_recursive=False, sync_users=True, import_by_dn=False)
      assert_equal(test_users.user_set.all().count(), 1)
      assert_equal(User.objects.get(username='posix_person').groups.all().count(), 0)

      # Import missing user
      ldap_access.CACHED_LDAP_CONN.add_posix_user_group_for_test('posix_person', 'PosixGroup')
      import_ldap_groups(ldap_access.CACHED_LDAP_CONN, 'PosixGroup', import_members=True, import_members_recursive=False, sync_users=True, import_by_dn=False)
      assert_equal(test_users.user_set.all().count(), 2)
      assert_equal(User.objects.get(username='posix_person').groups.all().count(), 1)

      # Import all members of PosixGroup and members of subgroups (there should be no subgroups)
      import_ldap_groups(ldap_access.CACHED_LDAP_CONN, 'PosixGroup', import_members=True, import_members_recursive=True, sync_users=True, import_by_dn=False)
      test_users = Group.objects.get(name='PosixGroup')
      assert_true(LdapGroup.objects.filter(group=test_users).exists())
      assert_equal(test_users.user_set.all().count(), 2)

      # Import all members of NestedPosixGroups and members of subgroups
      reset_all_users()
      reset_all_groups()
      import_ldap_groups(ldap_access.CACHED_LDAP_CONN, 'NestedPosixGroups', import_members=True, import_members_recursive=True, sync_users=True, import_by_dn=False)
      test_users = Group.objects.get(name='NestedPosixGroups')
      assert_true(LdapGroup.objects.filter(group=test_users).exists())
      assert_equal(test_users.user_set.all().count(), 0)
      test_users = Group.objects.get(name='PosixGroup')
      assert_true(LdapGroup.objects.filter(group=test_users).exists())
      assert_equal(test_users.user_set.all().count(), 2)

      # Make sure Hue groups with naming collisions don't get marked as LDAP groups
      hue_user = User.objects.create(username='otherguy', first_name='Different', last_name='Guy')
      hue_group = Group.objects.create(name='OtherGroup')
github niftools / blender_nif_plugin / testframework / unit / utility / test_utility.py View on Github external
def test_find_property(self):
        """Expect to find first instance of property"""
        self.n_ninode.add_property(self.ni_texture_prop)
        self.n_ninode.add_property(self.ni_mat_prop)
        self.n_ninode.add_property(self.ni_mat_prop1)
        nose.tools.assert_equals(self.n_ninode.num_properties, 3)

        prop = util_math.find_property(self.n_ninode, NifFormat.NiMaterialProperty)
        nose.tools.assert_true(prop == self.ni_mat_prop)
github MatthieuDartiailh / HQCMeas / tests / measurement / test_workspace.py View on Github external
def test_engine_contribution_observer1(self):
        """ Test engine selected before workspace starts does contribute.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        plugin.selected_engine = u'engine1'

        core = self.workbench.get_plugin(u'enaml.workbench.core')
        cmd = u'enaml.workbench.ui.select_workspace'
        core.invoke_command(cmd, {'workspace': u'hqc_meas.measure.workspace'},
                            self)
        process_app_events()

        assert_true(plugin.engines[u'engine1'].contributing)

        plugin.selected_engine = u''
        assert_false(plugin.engines[u'engine1'].contributing)
github pyros-dev / pyros / tests / pyros / mockinterface / nosetests / test_mockparam.py View on Github external
def test_echo_fortytwo():
    param = MockParam('random_param')
    assert_true(param.set(42))
    recv = param.get()
    print(recv)
    assert_true(recv == 42)
github fwenzel / reporter / apps / website_issues / tests.py View on Github external
def test_nonexistant_site(self):
        """Single site for nonexistent url gives 404."""
        for sentiment in ["happy", "sad", None]:
            params = dict(url_='this.is.nonexistent.com', protocol='http')
            view_url = reverse('single_site', kwargs=params)
            if sentiment is not None:
                view_url += '?sentiment=%s' % sentiment
            r = self.client.get(view_url)
            eq_(r.status_code, 404)
            assert_true(len(r.content) > 0)
github angr / angr / tests / test_string.py View on Github external
def test_strchr():
    l.info("concrete haystack and needle")
    s = SimState(arch="AMD64", mode="symbolic")
    str_haystack = s.solver.BVV(0x41424300, 32)
    str_needle = s.solver.BVV(0x42, 64)
    addr_haystack = s.solver.BVV(0x10, 64)
    s.memory.store(addr_haystack, str_haystack, endness="Iend_BE")

    ss_res = strchr(s, arguments=[addr_haystack, str_needle])
    nose.tools.assert_true(s.solver.unique(ss_res))
    nose.tools.assert_equal(s.solver.eval(ss_res), 0x11)

    l.info("concrete haystack, symbolic needle")
    s = SimState(arch="AMD64", mode="symbolic")
    str_haystack = s.solver.BVV(0x41424300, 32)
    str_needle = s.solver.BVS("wtf", 64)
    chr_needle = str_needle[7:0]
    addr_haystack = s.solver.BVV(0x10, 64)
    s.memory.store(addr_haystack, str_haystack, endness="Iend_BE")

    ss_res = strchr(s, arguments=[addr_haystack, str_needle])
    nose.tools.assert_false(s.solver.unique(ss_res))
    nose.tools.assert_equal(len(s.solver.eval_upto(ss_res, 10)), 5)

    s_match = s.copy()
    s_nomatch = s.copy()
github angr / angr / tests / test_sim_procedure.py View on Github external
nose.tools.assert_false(node.is_simprocedure)
    nose.tools.assert_false(node.is_syscall)
    nose.tools.assert_false(proj.is_hooked(node.addr))
    nose.tools.assert_false(func.is_syscall)
    nose.tools.assert_false(func.is_simprocedure)
    nose.tools.assert_equal(type(proj.factory.snippet(node.addr)), BlockNode)

    # check hooked functions
    proj.hook(0x80480a0, angr.SIM_PROCEDURES['libc']['puts']())
    cfg = proj.analyses.CFGFast(normalize=True)# rebuild cfg to updated nodes
    node = cfg.get_any_node(0x80480a0)
    func = proj.kb.functions[node.addr]

    nose.tools.assert_true(node.is_simprocedure)
    nose.tools.assert_false(node.is_syscall)
    nose.tools.assert_true(proj.is_hooked(node.addr))
    nose.tools.assert_false(func.is_syscall)
    nose.tools.assert_true(func.is_simprocedure)
    nose.tools.assert_equal(type(proj.factory.snippet(node.addr)), HookNode)
github CenterForOpenScience / osf.io / admin_tests / nodes / test_views.py View on Github external
def test_confirm_node_as_ham(self):
        view = NodeConfirmHamView()
        view = setup_log_view(view, self.request, guid=self.node._id)
        view.delete(self.request)

        self.node.refresh_from_db()
        nt.assert_true(self.node.spam_status == 4)
github angr / angr / tests / test_concrete_not_packed_elf32.py View on Github external
simgr = p.factory.simgr(new_concrete_state)
    #print("[2]Symbolically executing BINARY to find dropping of second stage [ address:  " + hex(DROP_STAGE2_V1) + " ]")
    exploration = simgr.explore(find=DROP_STAGE2_V1, avoid=[DROP_STAGE2_V2, VENV_DETECTED, FAKE_CC])
    if not exploration.stashes['found'] and exploration.errored and type(exploration.errored[0].error) is angr.errors.SimIRSBNoDecodeError:
        raise nose.SkipTest()
    new_symbolic_state = exploration.stashes['found'][0]

    binary_configuration = new_symbolic_state.solver.eval(arg0, cast_to=int)

    #print("[3]Executing BINARY concretely with solution found until the end " + hex(BINARY_EXECUTION_END))
    execute_concretly(p, new_symbolic_state, BINARY_EXECUTION_END, [(symbolic_buffer_address, arg0)])

    #print("[4]BINARY execution ends, the configuration to reach your BB is: " + hex(binary_configuration))

    correct_solution = 0xa000000f9ffffff000000000000000000000000000000000000000000000000
    nose.tools.assert_true(binary_configuration == correct_solution)
github baidu / tera / test / testcase / test_snapshot.py View on Github external
dump_file2 = 'dump2.out'
    scan_file1 = 'scan1.out'
    scan_file2 = 'scan2.out'
    common.run_tera_mark([(dump_file1, False)], op='w', table_name=table_name, cf='cf0:q,cf1:q', random='random',
                         key_seed=1, value_seed=10, value_size=100, num=10000, key_size=20)
    common.run_tera_mark([(dump_file1, True)], op='w', table_name=table_name, cf='cf0:q,cf1:q', random='random',
                         key_seed=1, value_seed=11, value_size=100, num=10000, key_size=20)
    snapshot = common.snapshot_op(table_name)
    common.run_tera_mark([(dump_file2, False)], op='w', table_name=table_name, cf='cf0:q,cf1:q', random='random',
                         key_seed=1, value_seed=10, value_size=100, num=10000, key_size=20)
    common.run_tera_mark([(dump_file2, True)], op='w', table_name=table_name, cf='cf0:q,cf1:q', random='random',
                         key_seed=1, value_seed=11, value_size=100, num=10000, key_size=20)
    common.compact_tablets(common.get_tablet_list(table_name))
    common.scan_table(table_name=table_name, file_path=scan_file1, allversion=True, snapshot=snapshot)
    common.scan_table(table_name=table_name, file_path=scan_file2, allversion=True, snapshot=0)
    nose.tools.assert_true(common.compare_files(dump_file1, scan_file1, need_sort=True))
    nose.tools.assert_true(common.compare_files(dump_file2, scan_file2, need_sort=True))