<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import unittest <EOL> from collections import OrderedDict <EOL> from io import StringIO <EOL> from tempfile import NamedTemporaryFile <EOL> from pants . backend . jvm . tasks . properties import Properties <EOL> class PropertiesTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_empty ( self ) : <EOL> self . assertLoaded ( '<STR_LIT>' , { } ) <EOL> self . assertLoaded ( '<STR_LIT:U+0020>' , { } ) <EOL> self . assertLoaded ( '<STR_LIT:\t>' , { } ) <EOL> self . assertLoaded ( '''<STR_LIT:U+0020>''' , { } ) <EOL> def test_comments ( self ) : <EOL> self . assertLoaded ( '''<STR_LIT>''' , { '<STR_LIT:a>' : '<STR_LIT>' } ) <EOL> def test_kv_sep ( self ) : <EOL> self . assertLoaded ( '''<STR_LIT>''' , { '<STR_LIT:a>' : '<STR_LIT:b>' , '<STR_LIT:c>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:f>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:g>' : '<STR_LIT>' , '<STR_LIT:h>' : '<STR_LIT>' , '<STR_LIT:i>' : '<STR_LIT>' } ) <EOL> def test_line_continuation ( self ) : <EOL> self . assertLoaded ( '''<STR_LIT>''' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:c>' : '<STR_LIT:d>' , '<STR_LIT:e>' : '<STR_LIT:f>' , '<STR_LIT:g>' : '<STR_LIT:h>' , '<STR_LIT:i>' : '<STR_LIT>' } ) <EOL> def test_stream ( self ) : <EOL> with NamedTemporaryFile ( ) as props_out : <EOL> props_out . write ( '''<STR_LIT>''' ) <EOL> props_out . flush ( ) <EOL> with open ( props_out . name , '<STR_LIT:r>' ) as props_in : <EOL> self . assertLoaded ( props_in , { '<STR_LIT>' : '<STR_LIT:file>' } ) <EOL> def assertLoaded ( self , contents , expected ) : <EOL> self . assertEquals ( expected , Properties . load ( contents ) ) <EOL> def test_dump ( self ) : <EOL> props = OrderedDict ( ) <EOL> props [ '<STR_LIT:a>' ] = <NUM_LIT:1> <EOL> props [ '<STR_LIT:b>' ] = '''<STR_LIT>''' <EOL> props [ '<STR_LIT:c>' ] = '<STR_LIT>' <EOL> out = StringIO ( ) <EOL> Properties . dump ( props , out ) <EOL> self . assertEquals ( '<STR_LIT>' , out . getvalue ( ) ) </s>
