<s> import re <EOL> import pytest <EOL> import networkzero as nw0 <EOL> nw0 . core . _enable_debug_logging ( ) <EOL> is_valid_ip = nw0 . core . is_valid_ip <EOL> is_valid_port = nw0 . core . is_valid_port <EOL> is_valid_address = nw0 . core . is_valid_address <EOL> class TestAddress ( object ) : <EOL> def test_none_supplied ( self ) : <EOL> canonical_address = nw0 . core . address ( ) <EOL> assert is_valid_address ( canonical_address , port_range = nw0 . config . DYNAMIC_PORTS ) <EOL> def test_valid_ip_supplied ( self ) : <EOL> address = "<STR_LIT:127.0.0.1>" <EOL> canonical_address = nw0 . core . address ( address ) <EOL> assert is_valid_address ( canonical_address ) <EOL> def test_valid_port_string_is_supplied ( self ) : <EOL> address = "<STR_LIT>" <EOL> canonical_address = nw0 . core . address ( address ) <EOL> assert is_valid_address ( canonical_address ) <EOL> def test_valid_port_int_is_supplied ( self ) : <EOL> address = <NUM_LIT> <EOL> canonical_address = nw0 . core . address ( address ) <EOL> assert is_valid_address ( canonical_address ) <EOL> def test_valid_port_zero_is_supplied ( self ) : <EOL> address = <NUM_LIT:0> <EOL> canonical_address = nw0 . core . address ( address ) <EOL> assert is_valid_address ( canonical_address , port_range = nw0 . config . DYNAMIC_PORTS ) <EOL> def test_valid_both_are_supplied ( self ) : <EOL> address = "<STR_LIT>" <EOL> canonical_address = nw0 . core . address ( address ) <EOL> assert is_valid_address ( canonical_address ) <EOL> def test_invalid_ip_supplied ( self ) : <EOL> address = "<STR_LIT>" <EOL> with pytest . raises ( nw0 . core . InvalidAddressError ) : <EOL> canonical_address = nw0 . core . address ( address ) <EOL> def test_invalid_port_supplied ( self ) : <EOL> address = <NUM_LIT> <EOL> with pytest . raises ( nw0 . core . AddressError ) : <EOL> canonical_address = nw0 . core . address ( address ) <EOL> def test_invalid_both_supplied ( self ) : <EOL> address = "<STR_LIT>" <EOL> with pytest . raises ( nw0 . core . AddressError ) : <EOL> canonical_address = nw0 . core . address ( address ) <EOL> class TestCommand ( object ) : <EOL> def test_action_only ( self ) : <EOL> commandline = "<STR_LIT>" <EOL> assert nw0 . core . action_and_params ( commandline ) == ( "<STR_LIT>" , [ ] ) <EOL> def test_action_and_one_param ( self ) : <EOL> commandline = "<STR_LIT>" <EOL> assert nw0 . core . action_and_params ( commandline ) == ( "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> def test_action_and_several_params ( self ) : <EOL> commandline = "<STR_LIT>" <EOL> assert nw0 . core . action_and_params ( commandline ) == ( "<STR_LIT>" , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_param_with_space ( self ) : <EOL> commandline = "<STR_LIT>" <EOL> assert nw0 . core . action_and_params ( commandline ) == ( "<STR_LIT>" , [ "<STR_LIT>" ] ) </s>
