Example #1
0
    def test_returns_strings(self):
        self.assertIsInstance(cumberbatch.first(), str)
        self.assertIsInstance(cumberbatch.last(), str)
        self.assertIsInstance(cumberbatch.full(), str)

        self.assertIsInstance(cumberbatch.first(clean=False), str)
        self.assertIsInstance(cumberbatch.last(clean=False), str)
        self.assertIsInstance(cumberbatch.full(clean=False), str)
    def test_returns_strings(self):
        self.assertIsInstance(cumberbatch.first(), str)
        self.assertIsInstance(cumberbatch.last(), str)
        self.assertIsInstance(cumberbatch.full(), str)

        self.assertIsInstance(cumberbatch.first(clean=False), str)
        self.assertIsInstance(cumberbatch.last(clean=False), str)
        self.assertIsInstance(cumberbatch.full(clean=False), str)
Example #3
0
    def test_clean_false_produces_dirty_words(self):
        found_first = False
        for i in range(1000):
            found_first = cumberbatch.first(
                clean=False) in cumberbatch.Lists.firstnames_unclean
            if found_first:
                break
        self.assertTrue(found_first)

        found_last = False
        for i in range(1000):
            found_last = cumberbatch.last(
                clean=False) in cumberbatch.Lists.lastnames_unclean
            if found_last:
                break
        self.assertTrue(found_last)

        found_full_dirty_part = False
        found_full = False
        for i in range(100000):
            fullname = cumberbatch.full(clean=False)
            try:
                (full_first, full_last) = fullname.split(' ')
                if not found_full_dirty_part:
                    found_full_dirty_part = (
                        full_first in cumberbatch.Lists.firstnames_unclean
                        or full_last in cumberbatch.Lists.lastnames_unclean)
                if not found_full:
                    found_full = fullname in cumberbatch.Lists.fullnames_unclean
                if found_full_dirty_part and found_full:
                    break
            except ValueError, e:
                raise ValueError(fullname)
    def test_clean_false_produces_dirty_words(self):
        found_first = False
        for i in range(1000):
            found_first = cumberbatch.first(clean=False) in cumberbatch.Lists.firstnames_unclean
            if found_first:
                break
        self.assertTrue(found_first)

        found_last = False
        for i in range(1000):
            found_last = cumberbatch.last(clean=False) in cumberbatch.Lists.lastnames_unclean
            if found_last:
                break
        self.assertTrue(found_last)

        found_full_dirty_part = False
        found_full = False
        for i in range(100000):
            fullname = cumberbatch.full(clean=False)
            try:
                (full_first, full_last) = fullname.split(' ')
                if not found_full_dirty_part:
                    found_full_dirty_part = (full_first in cumberbatch.Lists.firstnames_unclean or
                                             full_last in cumberbatch.Lists.lastnames_unclean)
                if not found_full:
                    found_full = fullname in cumberbatch.Lists.fullnames_unclean
                if found_full_dirty_part and found_full:
                    break
            except ValueError, e:
                raise ValueError(fullname)
    def test_no_dirty_words_if_clean(self):
        for i in range(100):
            self.assertNotIn(cumberbatch.first(), cumberbatch.Lists.firstnames_unclean)
            self.assertNotIn(cumberbatch.last(), cumberbatch.Lists.lastnames_unclean)

            fullname = cumberbatch.full()
            self.assertNotIn(fullname, cumberbatch.Lists.fullnames_unclean)
            try:
                (full_first, full_last) = fullname.split(' ')
                self.assertNotIn(full_first, cumberbatch.Lists.firstnames_unclean)
                self.assertNotIn(full_last, cumberbatch.Lists.lastnames_unclean)
            except ValueError, e:
                raise ValueError(fullname)
Example #6
0
def main():
    parser = argparse.ArgumentParser("python -m cumberbatch")
    parser.description = __doc__
    exclusive = parser.add_mutually_exclusive_group()
    exclusive.add_argument('--first', action='store_true', help="Only generate a first name.")
    exclusive.add_argument('--last', action='store_true', help="Only generate a last name.")
    parser.add_argument('--nsfw', action='store_true', help="Allow NSFW names.")
    opts = parser.parse_args()
    clean = not opts.nsfw
    if opts.first:
        print(cumberbatch.first(clean=clean))
    elif opts.last:
        print(cumberbatch.last(clean=clean))
    else:
        print(cumberbatch.full(clean=clean))
Example #7
0
    def test_no_dirty_words_if_clean(self):
        for i in range(100):
            self.assertNotIn(cumberbatch.first(),
                             cumberbatch.Lists.firstnames_unclean)
            self.assertNotIn(cumberbatch.last(),
                             cumberbatch.Lists.lastnames_unclean)

            fullname = cumberbatch.full()
            self.assertNotIn(fullname, cumberbatch.Lists.fullnames_unclean)
            try:
                (full_first, full_last) = fullname.split(' ')
                self.assertNotIn(full_first,
                                 cumberbatch.Lists.firstnames_unclean)
                self.assertNotIn(full_last,
                                 cumberbatch.Lists.lastnames_unclean)
            except ValueError, e:
                raise ValueError(fullname)
Example #8
0
"""

import cumberbatch

first_names = []
while True:
    name = cumberbatch.first()
    if name in first_names:
        break
    else:
        first_names.append(name)
print 'Generated {} clean first names before a repeat appeared.'.format(len(first_names))

last_names = []
while True:
    name = cumberbatch.last()
    if name in last_names:
        break
    else:
        last_names.append(name)
print 'Generated {} clean last names before a repeat appeared.'.format(len(last_names))

full_names = []
while True:
    name = cumberbatch.full()
    if name in full_names:
        break
    else:
        full_names.append(name)
print 'Generated {} clean full names before a repeat appeared.'.format(len(full_names))
Example #9
0
"""

import cumberbatch

first_names = []
while True:
    name = cumberbatch.first()
    if name in first_names:
        break
    else:
        first_names.append(name)
print 'Generated {} clean first names before a repeat appeared.'.format(len(first_names))

last_names = []
while True:
    name = cumberbatch.last()
    if name in last_names:
        break
    else:
        last_names.append(name)
print 'Generated {} clean last names before a repeat appeared.'.format(len(last_names))

full_names = []
while True:
    name = cumberbatch.full()
    if name in full_names:
        break
    else:
        full_names.append(name)
print 'Generated {} clean full names before a repeat appeared.'.format(len(full_names))