GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 93db10...2ff154 )
by Xianshun
01:01
created

HuffmanCompressionUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 30
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_huffman_binary() 0 9 1
A test_huffman_string() 0 18 1
1
import unittest
2
3
from pycompressor.huffman import HuffmanCompressor
4
5
6
class HuffmanCompressionUnitTest(unittest.TestCase):
7
8
    def test_huffman_binary(self):
9
        huffman = HuffmanCompressor()
10
        text = 'Hello World'
11
        bit_stream = huffman.compress_to_binary(text)
12
        self.assertFalse(bit_stream.is_empty())
13
        print(bit_stream.size())
14
        decompressed = huffman.decompress_from_binary(bit_stream)
15
        print(decompressed)
16
        self.assertEqual(text, decompressed)
17
18
    def test_huffman_string(self):
19
        huffman = HuffmanCompressor()
20
        original = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been ' \
21
                   'the industry standard dummy text ever since the 1500s, when an unknown printer took a galley ' \
22
                   'of type and scrambled it to make a type specimen book. It has survived not only five centuries, ' \
23
                   'but also the leap into electronic typesetting, remaining essentially unchanged. It was ' \
24
                   'popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, ' \
25
                   'and more recently with desktop publishing software like Aldus PageMaker including versions of ' \
26
                   'Lorem Ipsum. '
27
        print('before compression: ' + original)
28
        print('length: ' + str(len(original)))
29
        compressed = huffman.compress_to_string(original)
30
        print('after compression: ' + compressed)
31
        print('length: ' + str(len(compressed)))
32
        decompressed = huffman.decompress_from_string(compressed)
33
        print('after decompression: ' + decompressed)
34
        print('length: ' + str(len(decompressed)))
35
        self.assertEqual(original, decompressed)
36
37
38
if __name__ == '__main__':
39
    unittest.main()
40