mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Summary: First commit contains the initial code from Richard's branch. Second commit are the changes that I made during the writing process Third commit is the update to support category/topic pair for each commit Pull Request resolved: https://github.com/pytorch/pytorch/pull/47360 Reviewed By: ejguan Differential Revision: D24741003 Pulled By: albanD fbshipit-source-id: d0fcc6765968dc1732d8a515688d11372c7e653d
46 lines
2.0 KiB
Python
46 lines
2.0 KiB
Python
import unittest
|
|
import tempfile
|
|
from commitlist import CommitList
|
|
|
|
class TestCommitList(unittest.TestCase):
|
|
def test_create_new(self):
|
|
with tempfile.TemporaryDirectory() as tempdir:
|
|
commit_list_path = f'{tempdir}/commitlist.csv'
|
|
commit_list = CommitList.create_new(commit_list_path, 'v1.5.0', '7543e7e558')
|
|
self.assertEqual(len(commit_list.commits), 2143)
|
|
self.assertEqual(commit_list.commits[0].commit_hash, '7335f079ab')
|
|
self.assertTrue(commit_list.commits[0].title.startswith('[pt][quant] qmul and qadd'))
|
|
self.assertEqual(commit_list.commits[-1].commit_hash, '7543e7e558')
|
|
self.assertTrue(commit_list.commits[-1].title.startswith('Migrate minall, max, maxall'))
|
|
|
|
def test_read_write(self):
|
|
with tempfile.TemporaryDirectory() as tempdir:
|
|
commit_list_path = f'{tempdir}/commitlist.csv'
|
|
initial = CommitList.create_new(commit_list_path, 'v1.5.0', '7543e7e558')
|
|
initial.write_to_disk()
|
|
|
|
expected = CommitList.from_existing(commit_list_path)
|
|
expected.commits[-2].category = 'foobar'
|
|
expected.write_to_disk()
|
|
|
|
commit_list = CommitList.from_existing(commit_list_path)
|
|
for commit, expected in zip(commit_list.commits, expected.commits):
|
|
self.assertEqual(commit, expected)
|
|
|
|
def test_update_to(self):
|
|
with tempfile.TemporaryDirectory() as tempdir:
|
|
commit_list_path = f'{tempdir}/commitlist.csv'
|
|
initial = CommitList.create_new(commit_list_path, 'v1.5.0', '7543e7e558')
|
|
initial.commits[-2].category = 'foobar'
|
|
self.assertEqual(len(initial.commits), 2143)
|
|
initial.write_to_disk()
|
|
|
|
commit_list = CommitList.from_existing(commit_list_path)
|
|
commit_list.update_to('5702a28b26')
|
|
self.assertEqual(len(commit_list.commits), 2143 + 4)
|
|
self.assertEqual(commit_list.commits[-5], initial.commits[-1])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|