diff --git a/quiffen/core/qif.py b/quiffen/core/qif.py index a9a6451..ff3b1dd 100644 --- a/quiffen/core/qif.py +++ b/quiffen/core/qif.py @@ -161,10 +161,12 @@ def parse( # Allow for comments and blank lines at the top of sections # Also skip `!Clear:` lines to ignore flags such as `!Clear:AutoSwitch` + # Also skip `!Option:` lines to ignore flags such as `!Option:AutoSwitch` for i, line in enumerate(section_lines): if ( not line.strip() or line.strip().startswith("!Clear:") + or line.strip().startswith("!Option:") or line[0] == "#" ): continue diff --git a/tests/test_files/test_option_autoswitch.qif b/tests/test_files/test_option_autoswitch.qif new file mode 100644 index 0000000..b86e161 --- /dev/null +++ b/tests/test_files/test_option_autoswitch.qif @@ -0,0 +1,12 @@ +!Option:AutoSwitch +!Account +NMy Bank Account +D +TBank +^ +!Clear:AutoSwitch +!Option:AutoSwitch +!Account +NMy Bank Account +TBank +^ diff --git a/tests/test_qif.py b/tests/test_qif.py index 55fceee..5fe5068 100644 --- a/tests/test_qif.py +++ b/tests/test_qif.py @@ -44,6 +44,11 @@ def qif_file_with_clear_autoswitch(): return Path(__file__).parent / "test_files" / "test_clear_autoswitch.qif" +@pytest.fixture +def qif_file_with_option_autoswitch(): + return Path(__file__).parent / "test_files" / "test_option_autoswitch.qif" + + def test_create_qif(): """Test creating a Qif instance""" qif = Qif() @@ -1117,3 +1122,14 @@ def test_clear_autoswitch_ignored(qif_file_with_clear_autoswitch): qif = Qif.parse(qif_file_with_clear_autoswitch) assert len(qif.accounts) == 1 assert list(qif.accounts.keys()) == ["My Bank Account"] + + +def test_option_autoswitch_ignored(qif_file_with_option_autoswitch): + """Tests that `!Opiton:AutoSwitch` flag exported by Quicken + is ignored. + + Relates to discussion #92. + """ + qif = Qif.parse(qif_file_with_option_autoswitch) + assert len(qif.accounts) == 1 + assert list(qif.accounts.keys()) == ["My Bank Account"]