예제 #1
0
    def test_maps(self):
        try:
            maps = nis.maps()
        except nis.error as msg:
            # NIS is probably not active, so this test isn't useful
            if support.verbose:
                print("Test Skipped:", msg)
            # Can't raise TestSkipped as regrtest only recognizes the exception
            #   import time.
            return
        try:
            # On some systems, this map is only accessible to the
            # super user
            maps.remove("passwd.adjunct.byname")
        except ValueError:
            pass

        done = 0
        for nismap in maps:
            mapping = nis.cat(nismap)
            for k, v in mapping.items():
                if not k:
                    continue
                if nis.match(k, nismap) != v:
                    self.fail("NIS match failed for key `%s' in map `%s'" %
                              (k, nismap))
                else:
                    # just test the one key, otherwise this test could take a
                    # very long time
                    done = 1
                    break
            if done:
                break
예제 #2
0
 def test_maps(self):
     try:
         maps = nis.maps()
     except nis.error, msg:
         # NIS is probably not active, so this test isn't useful
         if test_support.verbose:
             print "Test Skipped:", msg
         # Can't raise TestSkipped as regrtest only recognizes the exception
         #   import time.
         return
예제 #3
0
    def _get(self, name, retrieve=1):

        if not name:
            return self

        elif str(name) in nis.maps():
            return nisMapContext(
                namingAuthority = self.namingAuthority,
                nameInContext   = self.nameInContext + name,
            )

        else:
            return NOT_FOUND
예제 #4
0
from test_support import verbose, TestFailed, TestSkipped
import nis

print 'nis.maps()'
try:
    maps = nis.maps()
except nis.error, msg:
    # NIS is probably not active, so this test isn't useful
    if verbose:
        raise TestFailed, msg
    # only do this if running under the regression suite
    raise TestSkipped, msg

done = 0
for nismap in maps:
    if verbose:
        print nismap
    mapping = nis.cat(nismap)
    for k, v in mapping.items():
        if verbose:
            print '    ', k, v
        if not k:
            continue
        if nis.match(k, nismap) <> v:
            print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
        else:
            # just test the one key, otherwise this test could take a
            # very long time
            done = 1
            break
    if done:
예제 #5
0
 def __iter__(self):
     for map in nis.maps():
         yield self.compoundParser(map)
예제 #6
0
print AP2.O_SHLOCK, AP2.O_EXLOCK
#pylint: disable-msg=E1101
print AP3.rpc_paths
#pylint: disable-msg=E1101
print AP4.rpc_paths
print AP5.subversion
print AP6.family
print AP6.type
print AP6.proto

print heapq.nsmallest(1, ['a', 'b'], key=lambda x: 'your mom')
print heapq.nlargest(1, ['a', 'b'], key=lambda x: 'your mom')
print min([], key=lambda x: 'your mom')
print max([], key=lambda x: 'your mom')
print match('foo', domain='lalala')
print maps('foo', domain='lalala')
webbrowser.open(autoraise=True)

######### This is not detectable using pylint machinery, I think.
# try:
#     print 'foo'
# except IOError, e:
#     print 'bar'
# else:
#     print 'baz'
# finally:
#     print 'zoinks'

######### This crashes pylint, so...  no.
# def generator_func():
#     while (yield 'Give me a cookie') != 'cookie':
예제 #7
0
from test_support import verbose, TestFailed, TestSkipped
import nis
print 'nis.maps()'
try:
    maps = nis.maps()
except nis.error, msg:
    # NIS is probably not active, so this test isn't useful
    if verbose:
        raise TestFailed, msg
    # only do this if running under the regression suite
    raise TestSkipped, msg
done = 0
for nismap in maps:
    if verbose:
        print nismap
    mapping = nis.cat(nismap)
    for k, v in mapping.items():
        if verbose:
            print '    ', k, v
        if not k:
            continue
        if nis.match(k, nismap) != v:
            print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
        else:
            # just test the one key, otherwise this test could take a
            # very long time
            done = 1
            break
    if done:
        break