Skip to content

Commit

Permalink
Make behave-django work with behave v1.2.7.dev3
Browse files Browse the repository at this point in the history
Adds an input validation function for argparse to our codebase,
which was originally included in behave's codebase. See #147.
  • Loading branch information
bittner committed May 8, 2023
1 parent 5c8b52e commit 1c52a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion behave_django/management/commands/behave.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import absolute_import

import sys
from argparse import ArgumentTypeError
from importlib import import_module

from behave.__main__ import main as behave_main
from behave.configuration import options as behave_options
from behave.configuration import valid_python_module
from django.core.management.base import BaseCommand

from behave_django.environment import monkey_patch_behave
Expand All @@ -15,6 +16,15 @@
)


def valid_python_module(path):
try:
module_path, class_name = path.rsplit('.', 1)
module = import_module(module_path)
return getattr(module, class_name)
except (ValueError, AttributeError, ImportError):
raise ArgumentTypeError("No module named '{path}' was found.")


def add_command_arguments(parser):
"""
Additional command line arguments for the behave management command
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
beautifulsoup4
behave@git+http://github.com/behave/[email protected].dev2 # behave>=1.2.7
behave[toml]@git+http://github.com/behave/[email protected].dev3 # behave>=1.2.7
django>=3.2

0 comments on commit 1c52a72

Please sign in to comment.