<commit_before>'''
Test suite for pyRFC3339.

'''

from datetime import datetime

from pyrfc3339 import generate, parse
from pyrfc3339.utils import timezone
import pytz

from nose.tools import eq_, raises

class TestCore():
    '''
    This test suite contains tests to address cases not tested in the doctests,
    as well as additional tests for end-to-end verification.

    '''
    def test_timezone_rounding(self):
        '''
        Test rounding of timezone values to the nearest second.

        '''
        eq_(timezone(5429), '+01:30')
        eq_(timezone(5431), '+01:31')

    def test_zero_offset(self):
        '''
        Both +00:00 and -00:00 are equivalent to the offset 'Z' (UTC).

        '''
        timestamp = '2009-01-01T10:02:03+00:00'
        dt = parse(timestamp)
        eq_(dt.tzinfo, pytz.utc)
        
        timestamp = '2009-01-01T10:02:03-00:00'
        dt = parse(timestamp)
        eq_(dt.tzinfo, pytz.utc)


    def test_parse_microseconds(self):
        '''
        Test parsing timestamps with microseconds.

        '''
        timestamp = '2009-01-01T10:02:03.25Z'
        dt = parse(timestamp)
        eq_(dt.microsecond, 250000)

    def test_generate_microseconds(self):
        '''
        Test generating timestamps with microseconds.

        '''
        dt = datetime(2009, 01, 01, 10, 02, 03, 500000, pytz.utc)
        timestamp = generate(dt, microseconds = True)
        eq_(timestamp, '2009-01-01T10:02:03.500000Z')

    def test_mixed_case(self):
        '''
        Timestamps may use either 'T' or 't' and either 'Z' or 'z'
        according to :RFC:`3339`.

        '''
        dt1 = parse('2009-01-01t10:01:02z')
        dt2 = datetime(2009, 1, 1, 10, 1, 2, tzinfo=pytz.utc)

        eq_(dt1, dt2)<commit_msg>Remove leading zeros from integers (they confuse 2to3).<commit_after>'''
Test suite for pyRFC3339.

'''

from datetime import datetime

from pyrfc3339 import generate, parse
from pyrfc3339.utils import timezone
import pytz

from nose.tools import eq_, raises

class TestCore():
    '''
    This test suite contains tests to address cases not tested in the doctests,
    as well as additional tests for end-to-end verification.

    '''
    def test_timezone_rounding(self):
        '''
        Test rounding of timezone values to the nearest second.

        '''
        eq_(timezone(5429), '+01:30')
        eq_(timezone(5431), '+01:31')

    def test_zero_offset(self):
        '''
        Both +00:00 and -00:00 are equivalent to the offset 'Z' (UTC).

        '''
        timestamp = '2009-01-01T10:02:03+00:00'
        dt = parse(timestamp)
        eq_(dt.tzinfo, pytz.utc)
        
        timestamp = '2009-01-01T10:02:03-00:00'
        dt = parse(timestamp)
        eq_(dt.tzinfo, pytz.utc)


    def test_parse_microseconds(self):
        '''
        Test parsing timestamps with microseconds.

        '''
        timestamp = '2009-01-01T10:02:03.25Z'
        dt = parse(timestamp)
        eq_(dt.microsecond, 250000)

    def test_generate_microseconds(self):
        '''
        Test generating timestamps with microseconds.

        '''
        dt = datetime(2009, 1, 1, 10, 2, 3, 500000, pytz.utc)
        timestamp = generate(dt, microseconds = True)
        eq_(timestamp, '2009-01-01T10:02:03.500000Z')

    def test_mixed_case(self):
        '''
        Timestamps may use either 'T' or 't' and either 'Z' or 'z'
        according to :RFC:`3339`.

        '''
        dt1 = parse('2009-01-01t10:01:02z')
        dt2 = datetime(2009, 1, 1, 10, 1, 2, tzinfo=pytz.utc)

        eq_(dt1, dt2)
{'fraction_non_alphanumeric': 0.1200335758254057, 'fraction_numerical': 0.0923335198656967, 'mean_word_length': 2.3255813953488373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5252750', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1162, 'n_words': 310}