

def test_slug_against_illegal_characters(self):
    'Regression test: disallow events with slugs with wrong characters.\n\n        Only [\\w-] are allowed.'
    data = {
        'slug': '',
        'host_1': Host.objects.all()[0].pk,
        'tags': Tag.objects.all(),
    }
    for slug in ['a/b', 'a b', 'a!b', 'a.b', 'a\\b', 'a?b']:
        with self.subTest(slug=self):
            data['slug'] = slug
            f = EventForm(data)
            self.assertEqual(f.is_valid(), False)
            self.assertIn('slug', f.errors)
    data['slug'] = 'a-b'
    f = EventForm(data)
    self.assertEqual(f.is_valid(), False)
    self.assertNotIn('slug', f.errors)

dataset/ETHPy150Open swcarpentry/amy/workshops/test/test_event.py TestEventViews.test_slug_against_illegal_characters/VarMisuse@76/156 `slug`->`self`