1import sys
2
3from twisted.internet import defer
4from twisted.trial import unittest
5
6import scrapy
7from tests.utils.testproc import ProcessTest
8
9
10class VersionTest(ProcessTest, unittest.TestCase):
11 command = "version"
12
13 @defer.inlineCallbacks
14 def test_output(self):
15 encoding = sys.stdout.encoding or "utf-8"
16 _, out, _ = yield self.execute([])
17 self.assertEqual(
18 out.strip().decode(encoding),
19 f"Scrapy {scrapy.__version__}",
20 )
21
22 @defer.inlineCallbacks
23 def test_verbose_output(self):
24 encoding = sys.stdout.encoding or "utf-8"
25 _, out, _ = yield self.execute(["-v"])
26 headers = [
27 line.partition(":")[0].strip()
28 for line in out.strip().decode(encoding).splitlines()
29 ]
30 self.assertEqual(
31 headers,
32 [
33 "Scrapy",
34 "lxml",
35 "libxml2",
36 "cssselect",
37 "parsel",
38 "w3lib",
39 "Twisted",
40 "Python",
41 "pyOpenSSL",
42 "cryptography",
43 "Platform",
44 ],
45 )
46