forked from lorien/grab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spider_meta.py
52 lines (36 loc) · 1.33 KB
/
spider_meta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from grab.spider import Spider
from tests.util import BaseGrabTestCase
class SpiderMetaTestCase(BaseGrabTestCase):
def test_root_spider_class(self):
self.assertEqual(Spider.Meta.abstract, True)
def test_inherited_class(self):
class Child(Spider):
pass
self.assertEqual(Child.Meta.abstract, False)
class AnotherChild(Spider):
# pylint: disable=no-init
class Meta:
abstract = True
self.assertEqual(AnotherChild.Meta.abstract, True)
class ChildOfChild(Child):
pass
self.assertEqual(ChildOfChild.Meta.abstract, False)
class AnoterhChildOfChild(Child):
# pylint: disable=no-init
class Meta:
abstract = True
self.assertEqual(AnoterhChildOfChild.Meta.abstract, True)
def test_meta_inheritance(self):
class SomeSpider(Spider):
# pylint: disable=no-init
class Meta:
some_foo = 'bar'
class Child(SomeSpider):
pass
self.assertEqual(Child.Meta.some_foo, 'bar')
def test_explicit_existence_of_abstract(self):
class SomeSpider(Spider):
# pylint: disable=no-init
class Meta:
some_foo = 'bar'
self.assertEqual(SomeSpider.Meta.abstract, False)