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

Internal change #1106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 8 additions & 5 deletions openhtf/core/phase_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ def __call__(self, phase_func: PhaseT) -> 'PhaseDescriptor':
phase.options.repeat_limit = self.repeat_limit
if self.run_under_pdb:
phase.options.run_under_pdb = self.run_under_pdb
if self.phase_name_case == PhaseNameCase.CAMEL:
name = phase.name if phase.options.name is None else phase.options.name
phase.options.name = inflection.camelize(name)
if self.stop_on_measurement_fail:
phase.options.stop_on_measurement_fail = self.stop_on_measurement_fail
if self.phase_name_case:
phase.options.phase_name_case = self.phase_name_case
return phase


Expand Down Expand Up @@ -233,8 +232,12 @@ def _asdict(self) -> Dict[Text, Any]:
@property
def name(self) -> Text:
if self.options.name and isinstance(self.options.name, str):
return self.options.name
return self.func.__name__
name = self.options.name
else:
name = self.func.__name__
if self.options.phase_name_case == PhaseNameCase.CAMEL:
name = inflection.camelize(name)
return name

@property
def doc(self) -> Optional[Text]:
Expand Down
11 changes: 11 additions & 0 deletions test/phase_descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,17 @@ def snake_cased_phase():

self.assertEqual(snake_cased_phase.name, 'SnakeCasedPhase')

def test_camel_phase_name_casing_formats_templated_name(self):
@phase_descriptor.PhaseOptions(
name='{snake}_cased_phase', phase_name_case=openhtf.PhaseNameCase.CAMEL
)
def snake_cased_phase():
"""Empty function to generate phase descriptor."""

self.assertEqual(
snake_cased_phase.with_args(snake='snake').name, 'SnakeCasedPhase'
)

def test_keep_phase_name_casing_does_not_change_name(self):

@phase_descriptor.PhaseOptions(phase_name_case=openhtf.PhaseNameCase.KEEP)
Expand Down