Skip to content

Commit

Permalink
Add some extra tests for good and bad cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 22, 2024
1 parent 97a4a07 commit bda871e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/briefcase/commands/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def make_app_name(self, formal_name):

def validate_formal_name(self, candidate):
"""Determine if the formal name is valid.
A formal name is valid if it contains at least one identifier character.
:param candidate: The candidate name
Expand Down
2 changes: 1 addition & 1 deletion src/briefcase/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def make_class_name(formal_name):
# If the first character isn't in the 'start' character set,
# and it isn't already an underscore, prepend an underscore.
if (
class_name != ""
class_name
and unicodedata.category(class_name[0]) not in xid_start
and class_name[0] != "_"
):
Expand Down
12 changes: 12 additions & 0 deletions tests/commands/new/test_validate_formal_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
@pytest.mark.parametrize(
"name",
[
# Various forms of capitalization and alphanumeric
"Hello World",
"helloworld",
"helloWorld",
"hello42world",
"42helloworld",
# Names that include punctuation
"hello_world",
"hello-world",
"_helloworld",
"/helloworld",
"Hello / World!",
# Internationalized names that can be unicode-simplified
"Hallo Vögel",
"Bonjour Garçon",
# Internationalized names that cannot be unicode-simplified
"你好 世界!",
],
)
def test_valid_formal_name(new_command, name):
Expand All @@ -22,6 +31,9 @@ def test_valid_formal_name(new_command, name):
@pytest.mark.parametrize(
"name",
[
"", # Empty
" ", # Just a space
"\t", # Other whitespace characters
"/", # Just a slash
"'",
"\\",
Expand Down

0 comments on commit bda871e

Please sign in to comment.