loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json, xmltodict, xml

def test_xmltodict():
  parsed = xmltodict.parse("""
    <div class="workspace-header-description-container">
      <img title="Python3" 
        src="/public/images/languages/python.svg" 
        class="workspace-header-lang-image"/>
      <p class="high">
        No description
      </p>
      <div>Div Example</div>
      <p>P Example</p>
    </div>
  """)
  jsonstr = json.dumps(parsed, indent=2)
  print(jsonstr)
  assert('div' in json.loads(jsonstr))

def test_xmltodicterror():
  try:
    xmltodict.parse("""
      <div>
        <div>Error Example
      </div>
    """)
  except xml.parsers.expat.ExpatError as e:
    assert('no element found' in str(e))
  
    
test_xmltodict()
test_xmltodicterror()