As explained in the package manual, the package generates a .snippets file and you must run the external program pygmentex on this file. The -shell-escape flag is not necessary for the LaTeX runs.
Relevant section of the manual (page 1 at the bottom):
When compiling the document (with pdflatex, for instance), all the
source code listings in the document wil be collected and saved in a
temporary file with the extension .snippets in its name. Then the
auxiliary program pygmentex (a Python application distributed with
the PygmenTEX package) should be run taking this file as input. It
will produce another temporary file with the extension .pygmented,
containing LATEX code for the code listings previously collected. The
next time the document is compiled, they are included to produce the
final typeset document.
For the example you can therefore use the following compile sequence:
xelatex test.tex
pygmentex test.snippets
xelatex test.tex
Result:
