def test_failed_search(self): node = Soupy('<a><b>1</b></a><a>2</a>') with pytest.raises(NullValueError): node.find_all('a').dump( a=Q.find('b').text )
def test_orelse(self): node = Soupy('<a><b>1</b></a><a>2</a>') result = node.find_all('a').dump( a=Q.find('b').text.map(int).orelse(0)).val() assert result == [{'a': 1}, {'a': 0}]
def test_orelse(self): node = Soupy('<a><b>1</b></a><a>2</a>') result = node.find_all('a').dump( a=Q.find('b').text.map(int).orelse(0) ).val() assert result == [{'a': 1}, {'a': 0}]
def test_chain_two_expressions(self): result = Q.find('a')._chain(Q.find('b')) assert len(result._items) == 6
def test_either_fallback(self): node = Soupy('<a><b>1</b></a><a>2</a>') assert isinstance(node.apply(either(Q.find('d').text, Q.find('d').text)), Null)
def test_either(self): node = Soupy('<a><b>1</b></a><a>2</a>') assert node.apply(either(Q.find('c').text, Q.find('b').text)).val() == '1'
def test_dump_with_method(self): node = Soupy('<a>1</a><a>2</a><a>3</a>') result = node.find_all('a').dump( a=Q.find('b').orelse('')).val() assert result == [{'a': ''}, {'a': ''}, {'a': ''}]
def test_chain_two_expressions(self): result = Q.find('a')._chain(Q.find('b')) assert len(result._items) == 6
def test_either_fallback(self): node = Soupy('<a><b>1</b></a><a>2</a>') assert isinstance( node.apply(either(Q.find('d').text, Q.find('d').text)), Null)
def test_either(self): node = Soupy('<a><b>1</b></a><a>2</a>') assert node.apply(either(Q.find('c').text, Q.find('b').text)).val() == '1'
def test_failed_search(self): node = Soupy('<a><b>1</b></a><a>2</a>') with pytest.raises(NullValueError): node.find_all('a').dump(a=Q.find('b').text)
def test_dump_with_method(self): node = Soupy('<a>1</a><a>2</a><a>3</a>') result = node.find_all('a').dump(a=Q.find('b').orelse('')).val() assert result == [{'a': ''}, {'a': ''}, {'a': ''}]