Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty testcases for AtCoder (e.g. AGC036 B) #554

Merged
merged 2 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion onlinejudge/service/atcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ def _find_sample_tags(cls, soup: bs4.BeautifulSoup) -> Iterator[Tuple[bs4.Tag, b
for pre in soup.find_all('pre'):
log.debug('pre tag: %s', str(pre))
if not pre.string:
continue
if len(pre.contents):
# <pre> element is not a sample but the input format
continue
# the sample is an empty string, so set pre.string as '' instead of None
pre.string = ''

def h3_plus(tag):
prv = tag.find_previous_sibling()
Expand Down
20 changes: 20 additions & 0 deletions tests/command_download_atcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ def test_call_download_atcoder_abc003_4(self):
},
], type='json')

def test_call_download_atcoder_agc036_b(self):
self.snippet_call_download('https://atcoder.jp/contests/agc036/tasks/agc036_b', [
{
"input": "3 2\n1 2 3\n",
"output": "2 3\n"
},
{
"input": "5 10\n1 2 3 2 3\n",
"output": "3\n"
},
{
"input": "6 1000000000000\n1 1 2 2 3 3\n",
"output": "\n"
},
{
"input": "11 97\n3 1 4 1 5 9 2 6 5 3 5\n",
"output": "9 2 6\n"
}
avtomat2023 marked this conversation as resolved.
Show resolved Hide resolved
], type='json')

def test_call_download_invalid_url(self):
self.snippet_call_download_raises(requests.exceptions.HTTPError, 'http://abc001.contest.atcoder.jp/tasks/abc001_100')

Expand Down