Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.source.test_abc_loader.SourceLoaderGetSourceTests Class Reference

List of all members.

Public Member Functions

def test_default_encoding
def test_decoded_source
def test_universal_newlines

Detailed Description

Tests for importlib.abc.SourceLoader.get_source().

Definition at line 733 of file test_abc_loader.py.


Member Function Documentation

Definition at line 746 of file test_abc_loader.py.

00746 
00747     def test_decoded_source(self):
00748         # Decoding should work.
00749         name = 'mod'
00750         mock = SourceOnlyLoaderMock("mod.file")
00751         source = "# coding: Latin-1\nx='ü'"
00752         assert source.encode('latin-1') != source.encode('utf-8')
00753         mock.source = source.encode('latin-1')
00754         returned_source = mock.get_source(name)
00755         self.assertEqual(returned_source, source)

Here is the call graph for this function:

Definition at line 737 of file test_abc_loader.py.

00737 
00738     def test_default_encoding(self):
00739         # Should have no problems with UTF-8 text.
00740         name = 'mod'
00741         mock = SourceOnlyLoaderMock('mod.file')
00742         source = 'x = "ü"'
00743         mock.source = source.encode('utf-8')
00744         returned_source = mock.get_source(name)
00745         self.assertEqual(returned_source, source)

Here is the call graph for this function:

Definition at line 756 of file test_abc_loader.py.

00756 
00757     def test_universal_newlines(self):
00758         # PEP 302 says universal newlines should be used.
00759         name = 'mod'
00760         mock = SourceOnlyLoaderMock('mod.file')
00761         source = "x = 42\r\ny = -13\r\n"
00762         mock.source = source.encode('utf-8')
00763         expect = io.IncrementalNewlineDecoder(None, True).decode(source)
00764         self.assertEqual(mock.get_source(name), expect)

Here is the call graph for this function:


The documentation for this class was generated from the following file: