Repository: kmyk/online-judge-tools
Pull request #187 (2018-11-03 19:42:36)

#186


Patch:
diff --git a/onlinejudge/aoj.py b/onlinejudge/aoj.py
index 9d1aceb..2782cdc 100644
--- a/onlinejudge/aoj.py
+++ b/onlinejudge/aoj.py
@@ -50,7 +50,7 @@ class AOJProblem(onlinejudge.problem.Problem):
         # get
         resp = utils.request('GET', self.get_url(), session=session)
         # parse
-        soup = bs4.BeautifulSoup(resp.content.decode(resp.encoding), 'html.parser')
+        soup = bs4.BeautifulSoup(resp.content, utils.html_parser)  # NOTE: resp.content is not decoded for workaround, see https://github.com/kmyk/online-judge-tools/pull/186
         samples = utils.SampleZipper()
         for pre in soup.find_all('pre'):
             log.debug('pre: %s', str(pre))


Test patch:
diff --git a/tests/download.py b/tests/download.py
index 0b23062..3741a60 100644
--- a/tests/download.py
+++ b/tests/download.py
@@ -35,14 +35,16 @@ class DownloadOthersTest(unittest.TestCase):
         snippet_call_download(self, *args, **kwargs)
 
     def test_call_download_hackerrank_beautiful_array(self):
-        if 'CI' not in os.environ:
-            self.snippet_call_download(
-                'https://www.hackerrank.com/contests/hourrank-1/challenges/beautiful-array', {
-                    'sample-1.in':  'fb3f7e56dac548ce73f9d8e485e5336b',
-                    'sample-2.out': '897316929176464ebc9ad085f31e7284',
-                    'sample-2.in':  '6047a07c8defde4d696513d26e871b20',
-                    'sample-1.out': '6d7fce9fee471194aa8b5b6e47267f03',
-                })
+        if 'CI' in os.environ:
+            print('NOTE: this test is skipped since login is required')
+            return
+        self.snippet_call_download(
+            'https://www.hackerrank.com/contests/hourrank-1/challenges/beautiful-array', {
+                'sample-1.in':  'fb3f7e56dac548ce73f9d8e485e5336b',
+                'sample-2.out': '897316929176464ebc9ad085f31e7284',
+                'sample-2.in':  '6047a07c8defde4d696513d26e871b20',
+                'sample-1.out': '6d7fce9fee471194aa8b5b6e47267f03',
+            })
 
     def test_call_download_anarchygolf_the_b_programming_language(self):
         self.snippet_call_download(
diff --git a/tests/download_aoj.py b/tests/download_aoj.py
index 8f89548..50e55fe 100644
--- a/tests/download_aoj.py
+++ b/tests/download_aoj.py
@@ -6,8 +6,10 @@ import os
 class DownloadAOJTest(unittest.TestCase):
 
     def snippet_call_download(self, *args, **kwargs):
-        if 'CI' not in os.environ:
-            tests.download.snippet_call_download(self, *args, **kwargs)
+        if kwargs.get('is_system'):
+            print('NOTE: this test is skipped since analytic.u-aizu.ac.jp:8080 is closed')
+            return
+        tests.download.snippet_call_download(self, *args, **kwargs)
 
     def test_call_download_aoj_DSL_1_A(self):
         self.snippet_call_download(
diff --git a/tests/download_yukicoder.py b/tests/download_yukicoder.py
index 843dff8..6421cb9 100644
--- a/tests/download_yukicoder.py
+++ b/tests/download_yukicoder.py
@@ -6,6 +6,9 @@ import os
 class DownloadYukicoderTest(unittest.TestCase):
 
     def snippet_call_download(self, *args, **kwargs):
+        if kwargs.get('is_system') and 'CI' in os.environ:
+            print('NOTE: this test is skipped since login is required')
+            return
         tests.download.snippet_call_download(self, *args, **kwargs)
 
     def test_call_download_yukicoder_no_9002(self):
@@ -61,27 +64,26 @@ class DownloadYukicoderTest(unittest.TestCase):
                 'sample-1.out': '90e2a51705594d033a3abe9d77b2b7ad',
             })
     def test_call_download_yukicoder_no_8_system(self):
-        if 'CI' not in os.environ:
-            self.snippet_call_download(
-                'https://yukicoder.me/problems/no/8', {
-                    '01.txt.in':  '04e90eb0c4a65eefa084dfea8e89de9f',
-                    '01.txt.out': 'fc07e56c1012af450b912af02f1e7c30',
-                    '02.txt.in':  'e867414a12769d8adc9086093620b4a3',
-                    '02.txt.out': '92289ff0469cfacb19a2809e6b44b93a',
-                    '03.txt.in':  'c15d6580553f2be2c4b133441da760f3',
-                    '03.txt.out': '5ff2d623f9ec55b7207a0e15f076a511',
-                    '04.txt.in':  'e28f58da56e572f4f27f9b837a4fe8c5',
-                    '04.txt.out': 'b9d27fd37514d704abe776e239029fae',
-                    '05.txt.in':  'd04e3cd98784a870b8dae31ab8e2c935',
-                    '05.txt.out': '559ffd2e020994c7117fdc38da1dd97d',
-                    '06.txt.in':  '897059f9374e64ed03e09a5b5044794c',
-                    '06.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
-                    '07.txt.in':  '69d224c83e03e0c3f6ff466fa06bc7dc',
-                    '07.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
-                    '08.txt.in':  'de61c37c042526933ac9ff5c99dd8681',
-                    '08.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
-                    '09.txt.in':  'b627b556c53cb20b9ae8fa4665925aa9',
-                    '09.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
-                    '10.txt.in':  '735f5246a7bde15f85ae368917eee087',
-                    '10.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
-                }, is_system=True)
+        self.snippet_call_download(
+            'https://yukicoder.me/problems/no/8', {
+                '01.txt.in':  '04e90eb0c4a65eefa084dfea8e89de9f',
+                '01.txt.out': 'fc07e56c1012af450b912af02f1e7c30',
+                '02.txt.in':  'e867414a12769d8adc9086093620b4a3',
+                '02.txt.out': '92289ff0469cfacb19a2809e6b44b93a',
+                '03.txt.in':  'c15d6580553f2be2c4b133441da760f3',
+                '03.txt.out': '5ff2d623f9ec55b7207a0e15f076a511',
+                '04.txt.in':  'e28f58da56e572f4f27f9b837a4fe8c5',
+                '04.txt.out': 'b9d27fd37514d704abe776e239029fae',
+                '05.txt.in':  'd04e3cd98784a870b8dae31ab8e2c935',
+                '05.txt.out': '559ffd2e020994c7117fdc38da1dd97d',
+                '06.txt.in':  '897059f9374e64ed03e09a5b5044794c',
+                '06.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
+                '07.txt.in':  '69d224c83e03e0c3f6ff466fa06bc7dc',
+                '07.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
+                '08.txt.in':  'de61c37c042526933ac9ff5c99dd8681',
+                '08.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
+                '09.txt.in':  'b627b556c53cb20b9ae8fa4665925aa9',
+                '09.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
+                '10.txt.in':  '735f5246a7bde15f85ae368917eee087',
+                '10.txt.out': 'a3d50a58dc67267b5e4619ecf73b2dcc',
+            }, is_system=True)