Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

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

After

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 TestVersionCommand(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 assert out.strip().decode(encoding) == f"Scrapy {scrapy.__version__}"
18
19 @defer.inlineCallbacks
20 def test_verbose_output(self):
21 encoding = sys.stdout.encoding or "utf-8"
22 _, out, _ = yield self.execute(["-v"])
23 headers = [
24 line.partition(":")[0].strip()
25 for line in out.strip().decode(encoding).splitlines()
26 ]
27 assert headers == [
28 "Scrapy",
29 "lxml",
30 "libxml2",
31 "cssselect",
32 "parsel",
33 "w3lib",
34 "Twisted",
35 "Python",
36 "pyOpenSSL",
37 "cryptography",
38 "Platform",
39 ]
40

Before

module
import_statement
import "import"
dotted_name
identifier "sys"
import_from_statement
from "from"
dotted_name
identifier "twisted"
. "."
identifier "internet"
import "import"
dotted_name
identifier "defer"
import_from_statement
from "from"
dotted_name
identifier "twisted"
. "."
identifier "trial"
import "import"
dotted_name
identifier "unittest"
import_statement
import "import"
dotted_name
identifier "scrapy"
import_from_statement
from "from"
dotted_name
identifier "tests"
. "."
identifier "utils"
. "."
identifier "testproc"
import "import"
dotted_name
identifier "ProcessTest"
class_definition
class "class"
identifier "VersionTest"
argument_list
( "("
identifier "ProcessTest"
, ","
attribute
identifier "unittest"
. "."
identifier "TestCase"
) ")"
: ":"
block
expression_statement
assignment
identifier "command"
= "="
string
string_start "\""
string_content "version"
string_end "\""
decorated_definition
decorator
@ "@"
attribute
identifier "defer"
. "."
identifier "inlineCallbacks"
function_definition
def "def"
identifier "test_output"
parameters
( "("
identifier "self"
) ")"
: ":"
block
expression_statement
assignment
identifier "encoding"
= "="
boolean_operator
attribute
attribute
identifier "sys"
. "."
identifier "stdout"
. "."
identifier "encoding"
or "or"
string
string_start "\""
string_content "utf-8"
string_end "\""
expression_statement (+22 nodes collapsed)
expression_statement
call
attribute
identifier "self"
. "."
identifier "assertEqual"
argument_list
( "("
call
attribute
call
attribute
identifier "out"
. "."
identifier "strip"
argument_list
( "("
) ")"
. "."
identifier "decode"
argument_list
( "("
identifier "encoding"
) ")"
, ","
string
string_start "f\""
string_content "Scrapy "
interpolation
{ "{"
attribute
identifier "scrapy"
. "."
identifier "__version__"
} "}"
string_end "\""
, ","
) ")"
decorated_definition
decorator
@ "@"
attribute
identifier "defer"
. "."
identifier "inlineCallbacks"
function_definition
def "def"
identifier "test_verbose_output"
parameters
( "("
identifier "self"
) ")"
: ":"
block
expression_statement
assignment
identifier "encoding"
= "="
boolean_operator
attribute
attribute
identifier "sys"
. "."
identifier "stdout"
. "."
identifier "encoding"
or "or"
string
string_start "\""
string_content "utf-8"
string_end "\""
expression_statement (+26 nodes collapsed)
expression_statement (+57 nodes collapsed)
expression_statement
call
attribute
identifier "self"
. "."
identifier "assertEqual"
argument_list
( "("
identifier "headers"
, ","
list (+58 nodes collapsed)
, ","
) ")"

After

module
import_statement
import "import"
dotted_name
identifier "sys"
import_from_statement
from "from"
dotted_name
identifier "twisted"
. "."
identifier "internet"
import "import"
dotted_name
identifier "defer"
import_from_statement
from "from"
dotted_name
identifier "twisted"
. "."
identifier "trial"
import "import"
dotted_name
identifier "unittest"
import_statement
import "import"
dotted_name
identifier "scrapy"
import_from_statement
from "from"
dotted_name
identifier "tests"
. "."
identifier "utils"
. "."
identifier "testproc"
import "import"
dotted_name
identifier "ProcessTest"
class_definition
class "class"
identifier "TestVersionCommand"
argument_list
( "("
identifier "ProcessTest"
, ","
attribute
identifier "unittest"
. "."
identifier "TestCase"
) ")"
: ":"
block
expression_statement
assignment
identifier "command"
= "="
string
string_start "\""
string_content "version"
string_end "\""
decorated_definition
decorator
@ "@"
attribute
identifier "defer"
. "."
identifier "inlineCallbacks"
function_definition
def "def"
identifier "test_output"
parameters
( "("
identifier "self"
) ")"
: ":"
block
expression_statement
assignment
identifier "encoding"
= "="
boolean_operator
attribute
attribute
identifier "sys"
. "."
identifier "stdout"
. "."
identifier "encoding"
or "or"
string
string_start "\""
string_content "utf-8"
string_end "\""
expression_statement (+22 nodes collapsed)
assert_statement
assert "assert"
comparison_operator
call
attribute
call
attribute
identifier "out"
. "."
identifier "strip"
argument_list
( "("
) ")"
. "."
identifier "decode"
argument_list
( "("
identifier "encoding"
) ")"
== "=="
string
string_start "f\""
string_content "Scrapy "
interpolation
{ "{"
attribute
identifier "scrapy"
. "."
identifier "__version__"
} "}"
string_end "\""
decorated_definition
decorator
@ "@"
attribute
identifier "defer"
. "."
identifier "inlineCallbacks"
function_definition
def "def"
identifier "test_verbose_output"
parameters
( "("
identifier "self"
) ")"
: ":"
block
expression_statement
assignment
identifier "encoding"
= "="
boolean_operator
attribute
attribute
identifier "sys"
. "."
identifier "stdout"
. "."
identifier "encoding"
or "or"
string
string_start "\""
string_content "utf-8"
string_end "\""
expression_statement (+26 nodes collapsed)
expression_statement (+57 nodes collapsed)
assert_statement
assert "assert"
comparison_operator
identifier "headers"
== "=="
list (+58 nodes collapsed)