Skip to content

Commit

Permalink
Added test case (skipped due to issue in dependency)
Browse files Browse the repository at this point in the history
  • Loading branch information
plonerma committed Nov 18, 2024
1 parent d55c333 commit 7a248fb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_field_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from pathlib import Path
from typing import Union
from typing import Optional, Union

import pytest
from config_classes import LongConfig as Config
Expand Down Expand Up @@ -153,3 +153,25 @@ def func(config: NonInitConfig):
],
global_config=global_config,
)


@pytest.mark.skip(
reason="issue within dependency (see: https://github.com/konradhalas/dacite/issues/244 )"
)
def test_non_init_optional_field(global_config):
@dataclass
class NonInitConfig:
a: int
b: Optional[float] = field(init=False)

def __post_init__(self):
self.b = float(self.a)

def func(config: NonInitConfig):
assert int(config.b) == config.a

cordage.run(func, args=["--a", "2"], global_config=global_config)

# Invoking the command with b should make the parser exit
with pytest.raises(SystemExit):
cordage.run(func, args=["--a", "2", "--b", "3"], global_config=global_config)

0 comments on commit 7a248fb

Please sign in to comment.