Skip to content

Commit

Permalink
Merge pull request #445 from kmyk/issue/444
Browse files Browse the repository at this point in the history
#444: fix a bug of AtCoderContest.get_penalty()
  • Loading branch information
fukatani authored Jun 14, 2019
2 parents 7383e28 + 7f13911 commit 94f4f7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion onlinejudge/service/atcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _load_details(self, session: Optional[requests.Session] = None, lang: str =
_, _, self._can_participate = soup.find('span', text=re.compile(r'^(Can Participate|参加対象): ')).text.partition(': ')
_, _, self._rated_range = soup.find('span', text=re.compile(r'^(Rated Range|Rated対象): ')).text.partition(': ')
penalty_text = soup.find('span', text=re.compile(r'^(Penalty|ペナルティ): ')).text
m = re.match(r'(Penalty|ペナルティ): (\d+)( minutes|分)', penalty_text)
m = re.match(r'(Penalty|ペナルティ): (\d+)( minutes?|分)', penalty_text)
assert m
self._penalty = datetime.timedelta(minutes=int(m.group(2)))

Expand Down
4 changes: 4 additions & 0 deletions tests/service_atcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def test_load_details(self):
self.assertEqual(contest.get_rated_range(), '-')
self.assertEqual(contest.get_penalty().total_seconds(), 5 * 60)

def test_get_penalty_a_singular_form(self):
contest = AtCoderContest.from_url('https://atcoder.jp/contests/chokudai_S002')
self.assertEqual(contest.get_penalty().total_seconds(), 60) # Penalty is written as "1 minute", not "1 minutes"

def test_list_problems(self):
contest = AtCoderContest.from_url('https://atcoder.jp/contests/agc028')
problems = contest.list_problems()
Expand Down

0 comments on commit 94f4f7b

Please sign in to comment.